473,388 Members | 1,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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="ITImageService.axd"
type="ITImageService.ITImageGetter,ITImageService" />
</httpHandlers>

The code for the handler looks like:

public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext context)
{
if(context.Session == null) { context.Response.Write("Session 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 2745
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="ITImageService.axd"
type="ITImageService.ITImageGetter,ITImageService" />
</httpHandlers>

The code for the handler looks like:

public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext context)
{
if(context.Session == null) { context.Response.Write("Session
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 IRequiresSessionState. Your HttpHandler class could be
like this:

public class MyHttpHandler: IHttpHandler , IRequiresSessionState
{
//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**************@TK2MSFTNGP11.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="ITImageService.axd"
type="ITImageService.ITImageGetter,ITImageService" />
</httpHandlers>

The code for the handler looks like:

public bool IsReusable { get { return true; } }
public void ProcessRequest(HttpContext context)
{
if(context.Session == null) { context.Response.Write("Session
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 IRequiresSessionState. Your HttpHandler class could

be like this:

public class MyHttpHandler: IHttpHandler , IRequiresSessionState
{
//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 IRequiresSessionState. Your HttpHandler class could be like this:

public class MyHttpHandler: IHttpHandler , IRequiresSessionState
{
//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)context.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**************@TK2MSFTNGP09.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
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...
3
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...
3
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...
6
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"...
8
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...
0
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...
0
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...
7
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: ...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.