Skip to content

*.dannyg

an extension of dannyg

Menu
  • Home
  • art
  • inspiration
  • music
  • poetry
  • Recipes
  • writings
Menu

URL Rewrites in WCF

Posted on May 12, 2009

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);
Technorati Tags: aspnet,url-rewriting,c-sharp

Leave a Reply

You must be logged in to post a comment.

Recent Posts

  • Reading Room
  • Inspirational Movies / TV shows
  • Remove passphrase from PEM file
  • Parallels Multihoming a CentOS Server
  • Forced Failures

Archives

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2026 *.dannyg | Design: Newspaperly WordPress Theme