views:

107

answers:

1

I have created my own custom httpmodule to handle url rewriting so that urls like www.contoso.com/help/default.aspx will point to www.contoso.com/default.aspx where the actual resource is located. This works fine, but because of my implementation of an httpmodule I am having problems with ScriptResource.axd not being run properly to add the javascript needed to perform button clicks or functionality afforded by ajax. I have IIS7 set to use the classic pipeline app pool. I have also ensured that the web.config file has the necessary information in it. I have pasted this information below. Can someone identify something that I have missed or should have configured differently?

A: 

Try adding something like this to your custom httpmodule:

public class MyModule : IHttpModule

{ public MyModule() { }

private void Application_OnAfterProcess(Object source, EventArgs e) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context;

if (context.Request.Headers["x-microsoftajax"] == null)
{
  if ((!System.IO.File.Exists(application.Request.PhysicalPath)) &&
    (!application.Request.Url.ToString().Contains(".axd")) &&
    (!application.Request.Url.ToString().Contains(".asmx")))
    {
      string newUrl = "~/Search.aspx?q=" 
        + context.Server.UrlEncode(application.Request.Url.Segments.Last());
      ...
      context.RewritePath(newUrl);
    }
 }

}

#region IHttpModule Members

void IHttpModule.Init(HttpApplication context) { context.PostResolveRequestCache += (new EventHandler(this.Application_OnAfterProcess)); } }

http://www.funtoyclub.com

monthclub