« Previous Next »

Thread: Programming content management system for IIS6 and 7 in one go

Last post 07-07-2009 3:22 PM by CarlosAg. 7 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (8 items)

Sort Posts:

  • 06-01-2009, 12:24 AM

    • hf_
    • Not Ranked
    • Joined on 06-01-2009, 4:17 AM
    • Posts 5

    Programming content management system for IIS6 and 7 in one go

     Hello, I have some questions;

    1. Is the recommended way of switching between different types of handlers if you want extensionless urls to use an HttpHandlerFactory?

    2. I'm using (1), and when I fail to handle the request in the CMS I want it to cascade down to the static file handler which has a number of improvements over anything I can build in managed code (response-time, security-integration, directory-listing reading settings, dynamic compression among other things).

    How do I do this? In IIS6 I:

    return new DefaultHttpHandler();

    but that doesn't work for IIS7 and I'm not even sure that's the same way I should do it in order to reap the benefits of the built-in static file handler. (In fact I don't think it is)

    My routing module knows whether my CMS can handle it or not; it that doesn't need to go into the httphandlerfactory.

    3. From the above discussion it's apparent that the httphandlerfactory in fact gobbles up the request for all handlers below, or otherwise I have no idea about how to make it not do that and pass the request down. If you know how, I would like to know.

    4. How important is it to implement pooling of IHttpHandlers, in terms of performance?

    5. Is there a way of providing your own cache, i.e. go around the built-in cache (for very specific reasons), without having threads killed by the runtime?

  • 06-01-2009, 2:06 AM In reply to

    • hf_
    • Not Ranked
    • Joined on 06-01-2009, 4:17 AM
    • Posts 5

    Re: Programming content management system for IIS6 and 7 in one go

     I need to clarify: I don't want to open security holes by serving anything. Firstly I think the previous http handlers denies anything in /security/requestFiltering/fileExtensions and secondly, I only want to serve files which I have the mime-mappings for.

    So again, it would be the best if I could serve the StaticFileModule,DefaultDocumentModule,DirectoryListingModule like normal. How do I do this?

  • 06-01-2009, 3:14 AM In reply to

    • hf_
    • Not Ranked
    • Joined on 06-01-2009, 4:17 AM
    • Posts 5

    Re: Programming content management system for IIS6 and 7 in one go

     The MS MVC (hello Haack) team does this:

                // Change the current path so that the Routing handler can correctly interpret
                // the request, then restore the original path so that the OutputCache module
                // can correctly process the response (if caching is enabled).

                string originalPath = Request.Path;
                HttpContext.Current.RewritePath(Request.ApplicationPath, false);
                IHttpHandler httpHandler = new MvcHttpHandler();
                httpHandler.ProcessRequest(HttpContext.Current);
                HttpContext.Current.RewritePath(originalPath, false);

     Could I do the same, with a nop httphandler and the rewrite the path back, in my httphandlerfactory?

  • 06-03-2009, 11:28 PM In reply to

    • hf_
    • Not Ranked
    • Joined on 06-01-2009, 4:17 AM
    • Posts 5

    Re: Programming content management system for IIS6 and 7 in one go

     bump

  • 06-15-2009, 7:32 PM In reply to

    • hf_
    • Not Ranked
    • Joined on 06-01-2009, 4:17 AM
    • Posts 5

    Re: Programming content management system for IIS6 and 7 in one go

    Bump again! I really would like an answer to my question! It's a hard question and I need help!

  • 07-07-2009, 2:13 PM In reply to

    Re: Programming content management system for IIS6 and 7 in one go

     Bump

  • 07-07-2009, 2:39 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,343

    Re: Programming content management system for IIS6 and 7 in one go

    MVC way is probably the only way to achieve this - leave the request mapped to StaticFile module, but add a handler mapping to your handler/handler-factory for some extension (say hf.axd) - also have a HttpModule which runs in OnMapRequestHandler and does RewritePath to same path with hf.axd added so it now gets routed to your handler/handler-factory.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 07-07-2009, 3:22 PM In reply to

    Re: Programming content management system for IIS6 and 7 in one go

    One thing I'm wondering if it would be possible to achieve something similar using URL Rewrite http://www.iis.net/extensions/URLRewrite by using a "Match All" expression but with a condition that only rewrites it to your handler (maybe a custom myhandler.axd) if the physical file/directory does not exist. This way if its a request for a physical file it will follow the normal execution and if allowed it will be served by the static file handler, and otherwise you will get it in your handler at which point your code should just work. If your handler doesnt match it in your CMS then you can just 404 it since we already know there is no physical file for it.

Page 1 of 1 (8 items)
Microsoft Communities