I had posted an entry to StackOverflow earlier today. But I was able to resolve before I got an answer. When handling URL rewrites in WCF, it’s important to include the trailing forward slash in the URL. You can this in my example below.
public class FormatModule : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
throw new NotImplementedException();
}
public void Init(HttpApplication application)
{
application.BeginRequest += new EventHandler(application_BeginRequest);
}
void application_BeginRequest(object sender, EventArgs e)
{
HttpContext context = HttpContext.Current;
if (context.Request.RawUrl.Contains(".pox"))
context.RewritePath("~/Lab1Service.svc?format=pox", false);
else if (context.Request.RawUrl.Contains(".json"))
context.RewritePath("~/Lab1Service.svc?format=json", false);
}
#endregion
}
What I needed to do was to include the trailing slash as seen below.
context.RewritePath("~/Lab1Service.svc/?format=pox", false);