473,568 Members | 2,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

custom http handler -- not reaching the session

I have written a custom http handler and added it to the web.config file

<httpHandlers >
<add verb="GET" path="ITImageSe rvice.axd"
type="ITImageSe rvice.ITImageGe tter,ITImageSer vice" />
</httpHandlers>

The code for the handler looks like:

public bool IsReusable { get { return true; } }
public void ProcessRequest( HttpContext context)
{
if(context.Sess ion == null) { context.Respons e.Write("Sessio n is
null"); return
}

A page adds some variables to the session and calls this handler url
http://localhost/myApp/ITImageService.axd
The handler writes "session is null" when there in fact is something in the
session.Why does the handler not reach teh session?
Nov 18 '05 #1
7 2756
mortb <mo****@hotmail .com> typed:
I have written a custom http handler and added it to the web.config
file

<httpHandlers >
<add verb="GET" path="ITImageSe rvice.axd"
type="ITImageSe rvice.ITImageGe tter,ITImageSer vice" />
</httpHandlers>

The code for the handler looks like:

public bool IsReusable { get { return true; } }
public void ProcessRequest( HttpContext context)
{
if(context.Sess ion == null) { context.Respons e.Write("Sessio n
is null"); return
}

A page adds some variables to the session and calls this handler url
http://localhost/myApp/ITImageService.axd
The handler writes "session is null" when there in fact is something
in the session.Why does the handler not reach teh session?


Try to Inherith from IRequiresSessio nState. Your HttpHandler class could be
like this:

public class MyHttpHandler: IHttpHandler , IRequiresSessio nState
{
//class implementation
}

Read this to more info:
http://msdn.microsoft.com/library/de...ClassTopic.asp

--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
Nov 18 '05 #2
Thanks a lot!

/mortb

"Davide Vernole [MVP]" <da****@online. knodev.com> wrote in message
news:um******** ******@TK2MSFTN GP11.phx.gbl...
mortb <mo****@hotmail .com> typed:
I have written a custom http handler and added it to the web.config
file

<httpHandlers >
<add verb="GET" path="ITImageSe rvice.axd"
type="ITImageSe rvice.ITImageGe tter,ITImageSer vice" />
</httpHandlers>

The code for the handler looks like:

public bool IsReusable { get { return true; } }
public void ProcessRequest( HttpContext context)
{
if(context.Sess ion == null) { context.Respons e.Write("Sessio n
is null"); return
}

A page adds some variables to the session and calls this handler url
http://localhost/myApp/ITImageService.axd
The handler writes "session is null" when there in fact is something
in the session.Why does the handler not reach teh session?
Try to Inherith from IRequiresSessio nState. Your HttpHandler class could

be like this:

public class MyHttpHandler: IHttpHandler , IRequiresSessio nState
{
//class implementation
}

Read this to more info:
http://msdn.microsoft.com/library/de...ClassTopic.asp
--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer

Nov 18 '05 #3
Two more questions:

* Do I have access to the cache (like context.Cache etc) or do I need to
inherit for that also?
* How do I debug my httpHandler? VisualStudio does not step into the code
when run.

cheers,
mortb
Try to Inherith from IRequiresSessio nState. Your HttpHandler class could be like this:

public class MyHttpHandler: IHttpHandler , IRequiresSessio nState
{
//class implementation
}

Read this to more info:
http://msdn.microsoft.com/library/de...ClassTopic.asp
--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer

Nov 18 '05 #4
mortb <mo****@hotmail .com> typed:
Two more questions:

* Do I have access to the cache (like context.Cache etc) or do I need
to inherit for that also?
Yes, you can without any other interface or class. Do that using the
HttpContext context object inside the ProcessRequest function:

MyObject object = (MyObject)conte xt.Cache["MyCachedObject "]
* How do I debug my httpHandler? VisualStudio does not step into the
code when run.

You can debug as usual. Are you sure to be in debug mode ?

--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
Nov 18 '05 #5
>
You can debug as usual. Are you sure to be in debug mode ?


Yes I am in debug mode
I step into the code on the pages but not into this http handler
It is located in another assembly, but so are other class libraries that I
use in my applicaiton and I am able to debug them.

/mortb
Nov 18 '05 #6
mortb <mo****@hotmail .com> typed:
Yes I am in debug mode
I step into the code on the pages but not into this http handler
It is located in another assembly, but so are other class libraries
that I use in my applicaiton and I am able to debug them.


Refer the project of your assembly insted of the assemby dll in your main
project. This should resolve the problem.

--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer
Nov 18 '05 #7
Doh, should've thought of that....
Thank you very much for your time!

cheers,
mortb
"Davide Vernole [MVP]" <da****@online. knodev.com> wrote in message
news:OZ******** ******@TK2MSFTN GP09.phx.gbl...
mortb <mo****@hotmail .com> typed:
Yes I am in debug mode
I step into the code on the pages but not into this http handler
It is located in another assembly, but so are other class libraries
that I use in my applicaiton and I am able to debug them.


Refer the project of your assembly insted of the assemby dll in your main
project. This should resolve the problem.

--
Davide Vernole
MVP ASP/ASP.NET
Microsoft Certified Solution Developer

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3245
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A query-string flag is used to indicate to the page whether it should instantiate a new instance of the object or access an existing instance from the...
3
1709
by: Mads Brydegaard | last post by:
Hi, I have created a custom Config handler for reading a custom config section in my .config file(s) It works very well! I have placed a web.config in my root directory and then I use sub files in sub diretories overriding various settings in the config file. Very nice strategy which really makes it easy to customize generic applications.
3
1527
by: Hope Paka | last post by:
I want to use my custom url extension instead of .aspx. I can achieve this by writing a custom handler that implements the IHttpHandlerFactory. In the GetHandler method of the IHttpHandlerFactory i want to construct a Page class instance and load my other controls to it and return the page instance. This is what .net framework does. There is...
6
3791
by: Tabi | last post by:
Hi, I want to create a custom section in my web.config that can hold my custom values. I created a section in web.config as written below. <configSections> <section name="myCustomSection" type="ComIT.Applications.Common.ConfigurationSections.MyHandler" allowLocation="true" allowDefinition="Everywhere" /> </configSections>
8
3880
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really need to avoid the extra round-trip to the client. I've tried Passing the page name, the full URL, and the instance of the handler class to the...
0
3214
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te documentation it seems it should do it anyway any advice?
0
1573
by: gilly3 | last post by:
I'm coming across all kinds of frustration implementing custom errors in ASP.NET 1.1. First, 401 - Authorization Failed My application uses Windows Integrated Authentication, and restricts access to a single Windows User Group like this (in web.config): <authorization> <allow roles="Domain\UserGroup" />
7
4681
by: ADN | last post by:
Hi, I am creating a custom HTTPModule to intercept the request of when the user is attempting to retrieve a session variable. For instance, if I set a session variable in my code like so: session = "Hello World"; When the request for that session variable "myString" is attempted to be retrieved, I would like to intercept that request like...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.