httpmodule is not being invoked

Discussion in 'ASP.NET 2.0' started by Hoosier121, Sep 7, 2009.

  1. Hi

    Hopefully someone can help. I have written an httpmodule that does a urlrewrite. This works fine on my development machine, but it seems that the httpmodule is not being invoked when deployed on discountasp.net. The prod server is Win 2003 IIS 6.

    web config section

    <system.web>
    <httpModules>
    <add type="SEO.UrlRewriter, App_Code" name="UrlRewriter"/>
    </httpModules>

    my httpmodule

    public class UrlRewriter : IHttpModule
    {

    #region IHttpModule Members

    public void Init(HttpApplication context)
    {
    context.BeginRequest += new EventHandler(rewriteUrl);
    }

    public void Dispose()
    {
    // Nothing To Do
    }
    #endregion

    private void rewriteUrl(object sender, EventArgs e)
    {
    HttpApplication myApp = (HttpApplication)sender;

    HttpContext ctx = myApp.Context;

    String currentPath = ctx.Request.Path;

    // the URL contains this folder name
    if (currentPath.ToLower().Contains("/articles/"))
    {

    // rewrite the URL
    ctx.RewritePath("articles.aspx?article="
    + currentPath.Substring(currentPath.LastIndexOf("/") + 1).Replace("-", " ").Replace(".html", ""));
    }


    }
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    .html is not handled by ASP.NET on IIS 6 by default.

    Contact support to add wildcard mapping to point to asp.net
     

Share This Page