.shtml HttpHandler

Discussion in 'ASP.NET 2.0' started by Killer Shrike, Feb 26, 2007.

  1. I moved my website over to this host this weekend. I used a lot of SHTML on my previous host, but it was easy to write a little console app to roll thru my site and remap / relink to .aspx instead. Thats all working, no problems.

    However, there are hundreds of links scattered all over the place onexternal sitesto my shtml pages and I'd like to redirect them gracefully.

    So, Ive added a simple HTTP handler like so:


    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    namespace KillerShrike
    {
    public class ShtmlHandler : IHttpHandler
    {
    public void ProcessRequest(HttpContext context)
    {
    context.Response.Redirect(context.Request.RawUrl.Replace(".shtml",".aspx"));
    }
    public bool IsReusable
    {
    get { return true; }
    }
    }
    }

    and Ive added this node to thehttpHandlers groupinmy web.config:

    <add verb="*"
    path="*.shtml"
    type="KillerShrike.ShtmlHandler, KillerShrike" />


    Works perfectly when I run it locally.

    So, in the IIS manager in the site controls I added .shtml as a MIME type. I tried every single mime type I could think of ranging from text/html to application/octet-stream and i still get the IIS 404 error.

    What I would expect to happen is for IIS to use the custom MIME type to let .shtml pass thru and then the httpHandler would jump on it and resolve it correctly as it does locally.


    Any ideas whats going wrong here?

    Thanks!
     
  2. You need to ask the technical support to map 'shtml' to ISAPI .Generally, its preferable to ask for a wild card mapping.

    Mime type is just the way IIS sends info to the browser in HTTP header.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Thanks for the response...

    According to the default MIME list provided therealready seems tobe a wildcard mapping to application/octet-stream





    .*
    application/octet-stream





    or do you mean something else?
     
  4. It's not the MIME setting that's applicable in this case. You'll need to have the application extension for .shtml remapped to aspnet_isapi.dll. Please send a support ticket to have this done.

    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. Cool. This worked. The HTTPHandler is doing its job, redirecting the pages seamlessly now.
     

Share This Page