locked
HttpHandler that uses the entire URL, but no requirement for physical folders RRS feed

  • Question

  • User1760591762 posted

    I'm trying to do something similar to URL rewriting. I'm currently using a handler to look at the URL requrested (/something/123 where /something is the web application) and based on the number, do some special processing. It works great right now, but the problem is it only works when there is a physical folder /123 on the file system within /something. This isn't what I want... I'd like for there to be no subfolders.

    So far I've run dry on finding a solution. I'm totally open to creating a custom httpmodule as well if that helps, but I'm not sure how it would...

    Thursday, October 11, 2007 2:02 PM

Answers

All replies

  • User-627724879 posted

    You need to make sure IIS is configured to not require the physical file; 'Verify File Exist'. Otherwise it assumes it is a hacker trying to access non-existent files for a buffer overrun.

    Here is a Blog entry made from part of my presentation on httpModules and httpHandlers, http://professionalaspnet.com/archive/2007/09/23/Streaming-a-vCard-on-the-Fly-in-ASP.NET-with-a-Custom-httpHandler.aspx. I think this is going to be pretty close to what you are trying to do.

    Here is another entry on wildcard extensions in ASP.NET, http://professionalaspnet.com/archive/2007/09/03/Create-an-HttpModule-to-Process-Wildcard-Extension-Mapping-in-ASP.NET.aspx.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 11, 2007 2:43 PM
  • User1760591762 posted

    Is there absolutely no way to do this without configuring IIS to not do the file exists check? Trying to do this in a hosted environment with zero access to IIS.

    Thursday, October 11, 2007 3:03 PM
  • User-627724879 posted

    sadly I do not think so. This is a built in security check for IIS 6. I know what you are saying though and that is why I have my own servers. For my clients that either have their own IT depts. or another hosting company I have to wrote so much code to manage as much as possible without dealing with those guys. The good news is if they are a sharp hosting company/IT dept then they know they can configure this on a site by site basis.

    Thursday, October 11, 2007 7:43 PM
  • User1760591762 posted

    While I hear what you're saying, I have to say I think there must be a way. The SubText blog project does just this... for instance, if you go to any post on my blog, the only physical folder that is there is /blog... there is no /archive or anything like that. Just wierd. I'll keep looking and post back what I find.

    I've just been picking through the source unable to figure out how the magic happens.

    Thanks for the input!

    Thursday, October 11, 2007 8:47 PM
  • User-627724879 posted

    If you can download the source code to SubText then I would try to figure out how they do it. Or ask on their forums, but as far as I know you have to configure IIS first. You can check out the FAQ on URLRewriting.net and their documentation. http://urlrewriting.net/en/FAQ.aspx

    Friday, October 12, 2007 2:49 PM
  • User1760591762 posted

    Got the source and talked to some of the devs... the trick (magic) is that the 404's map to an ASPX so it stays in the lifecycle.

    Friday, October 12, 2007 3:02 PM
  • User-627724879 posted

    Right you have to map whatevery extension you need through the ASP.NET engine. Here is my article on mapping wild card extensions.

    http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx

    Saturday, October 13, 2007 2:31 PM
  • User1760591762 posted

    No... sorry I didn't explain that correctly. There are zero IIS config requirements for the SubText implementation.

    Saturday, October 13, 2007 6:38 PM