Search code examples
c#wcfurl-rewriting

can we do URL-REWRITE for WCF


We have built a WCF service for our customers and deployed the dlls. Everything works perfectly, but we have been told we have to change the URL of the WCF.

Lets say, our current WCF URL is like below

https://xxx.xxxxx.xxx/EGov/PostBox.svc

Now, they want us to change that URL to

https://xxx.xxxxx.xxx/EGov/TransferService.svc

It is easy to change the file name from PostBox.svc to TransferService.svc but we have do it for our 100 customers and that is impossible. So, we are wondering if we can do URL-REWRITE from CONFIG files.

If we can do the URL-REWRITE from config files, then we will email the config files to each customer to put it into the right folder.

I hope I made my question clear.


Solution

  • No sure whether this will help you but i had some similar scenario where i have to rewrite the URL(for me i didn't have to show .svc file name to users.

        public class Route : IHttpModule
       {
        public void Dispose()
        {
        }
        public void Init(HttpApplication context)
        {
            context.BeginRequest += delegate
            {
                //URL Rewriting 
                //---To remove the .svc extension service file name from URL----
                 HttpContext cxt = HttpContext.Current;
                string path = cxt.Request.AppRelativeCurrentExecutionFilePath;
                {
                    cxt.RewritePath(path.Insert(1, "/ReportingService.svc"), false);
                }
    
            };
        }
    }
    

    Hopefully this will help you at least in some way