newbie questions on http handler

  • Thread starter Thread starter Raymond Du
  • Start date Start date
R

Raymond Du

Hi,

I have questions about http handler:
(1) Does it always ends with .ashx, the articles I read said http handler is
for developers to create something to handle different kind of files
extension, but all example I saw use .ashx.
(2) It does not inherit from Page class at all. Right? If it does not
inherit fro Page, how do I access Request, Response, Session or Application?

TIA
 
Raymond said:
(1) Does it always ends with .ashx, the articles I read said http handler is
for developers to create something to handle different kind of files
extension, but all example I saw use .ashx.

You can do this:

1) register a different extension with IIS (in application properties),
and map it to the aspnet_isapi.dll (same as .ashx is)

2) add a mapping to the httpHandlers section web.config (see how .ashx
is registered in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config)

See e.g. this page for more details:

http://www.theserverside.net/tt/articles/showarticle.tss?id=IIS_ASP

Typically it's easiest just to stick with .ashx though.
(2) It does not inherit from Page class at all. Right? If it does not
inherit fro Page, how do I access Request, Response, Session or Application?

Implementing IHttpHandler / IHttpAsyncHandler, there's a ProcessRequest
/ BeginProcessRequest method that you implement, and ASP.NET calls you.
It passes in a HttpContext argument. HttpContext has properties such as
Request, Response, etc.

-- Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top