Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

HTTPHandler configuration question

This is more of a IIS configuration question, than a .NET question, but I'm trying to figure out how to map URLs of the following form:

http://myhost/virtualdirectory/a
http://myhost/virtualdirectory/b

to my custom HTTPHandler.

The only way I configure out how the execute my HTTPHandler is by executing the web.config file like this:

http://myhost/virtualdirectory/web.config

I know there must be a better way, but I can't make sense of the docs.

Thanks,

Christopher

christopher baus (www.baus.net)
Monday, June 14, 2004

After reading this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfhttphandlerssection.asp

It sounds like the only way to do it is by mapping an extension to the handler.  That seems really weird.  I am missing something here?

christopher baus (www.baus.net)
Monday, June 14, 2004

What, exactly, is your question? Is it:

- How can I map a handler to two specific URLs; namely /virtualdirectoy/a and /virtualdirectory/b?

Or:

- How can I map a handler that handles all URLs?

Brad Wilson (dotnetguy.techieswithcats.com)
Monday, June 14, 2004

How can I map:

http://myhost/virtualdirectory/a (no extension) -> HandlerOne
http://myhost/virtualdirectory/b (no extension) -> HandlerTwo

christopher baus (www.baus.net)
Tuesday, June 15, 2004

You can map the wildcard "*" extension in IIS to aspnet_isapi and then map the handlers in web.config. But it's a bit of a can of worms (albeit not insurmountable). See http://www.interact-sw.co.uk/iangblog/2004/01/12/shinyurl for a discussion,

Duncan Smart
Tuesday, June 15, 2004

This is annoying me.  I can't get this to work. 

In my virtual host I have something like:

Application Extension Mapping

c:\path\to\my\assembly\supercoolassembly.dll *

In my web.config I have:

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="a" type="myNamespace.myHandler, myNamespace"/>
    </httpHandlers>
  </system.web>
</configuration>

And no go...

christopher baus (www.baus.net)
Tuesday, June 15, 2004

Grumble, Grumble...

should stick with Java...

... grumble, grumble...

I'm getting internal server error.  Is there anyway to get more information from the logs?  The logging looks like basic access logging.  Is there there an error log for IIS as well?

Do people really use IIS in production?  This is crazy.

christopher baus (www.baus.net)
Tuesday, June 15, 2004

> You can map the wildcard "*" extension in IIS to aspnet_isapi and then map the handlers in web.config.

Ok that's the trick.  I think I understand it now.  IIS sends all requests for the Virtual Directory to the aspnet_isapi.  This inturn reads the web.config file.  The web.config file maps certain requests to specific Handler based on the path attribute in the add tag. 

Ok.  whew.  I almost lost my cool there. 

christopher baus (www.baus.net)
Tuesday, June 15, 2004

Sounds like you've got it, but this will help in the future when working with IIS:

Regarding the Internal Server Error, I assume you're seeing this in IE.  Make sure you've turned off "friendly HTTP errors" in IE.  It's unreal the number of (even seasoned, MS-centric) web app developers who are unaware of this, and don't mind getting error messages that say absolutely nothing.

Under Tools -> Internet Options -> Advanced Tab

About 1/3 of the way down, within the "Browsing" section:

"Show friendly HTTP error messages"

Uncheck it to see what's actually broken when something goes wrong.

Ian Olsen
Wednesday, June 16, 2004

How can I map:

http://myhost/virtualdirectory/a (no extension) -> HandlerOne
http://myhost/virtualdirectory/b (no extension) -> HandlerTwo

Use the <location> element of web.config.

And....
<add verb="*" path="a" type="myNamespace.myHandler, myNamespace"/>

should be...
<add verb="*" path="a" type="namespace.class, assembly"/>

asdfasdf
Saturday, June 26, 2004

<configuration>
<location path="a">
      <system.web>
        <httpHandlers>
            <add verb="*" path="*.*" type="YourNamespace,YourClass, YourAssemblyName" />
        </httpHandlers>
      </system.web>
  </location>
  <location path="b">
    <system.web>
        <httpHandlers>
            <add verb="*" path="*.*" type="YourNamespace,YourClass,YourAssemblyName" />
        </httpHandlers>
    </system.web>
  </location> 
</configuration>

asdfasdf
Saturday, June 26, 2004

*  Recent Topics

*  Fog Creek Home