Search code examples
azurewcf-data-serviceshttpmodule

Azure WebRole and WCF Data Service - Preventing Redirect


I have a WCF Data service hosted in Azure as a Azure Web Role. Have added a Http Module for authentication. The custom Http Module looks at the Authorization header in the request headers and authenticates the user.

When I make a Http request to the WCF Data Service, I run into two issues. There is a Http redirect happening.

I make the request to http:\northwindsample.cloudapp.net\SampleService.svc. The message I get is that "There is no operation listening for http://rd00155d341b52/SampleService.svc, but there is an operation listening for http://northwindsample.cloudapp.net/SampleService.svc/, so you are being redirected there.

Though I am making the request to http:\northwindsample.cloudapp.net\SampleService.svc, it is somehow going to http://rd00155d341b52/SampleService.svc and then gets redirected to the actual service. I get an Http 307 and in the redirect the authorization header is missing.

Later I found that when I add the trailing slash, then there is no redirect happening. How can I prevent this redirection because of missing trailing slash ? Also the issue is that the authorization header is not sent to the redirected Uri.

Thanks


Solution

  • Take a look at this:

    http://gavinmckay.wordpress.com/2009/03/24/howto-fix-wcf-host-name-on-iis/

    For updating this in Azure, you will want to either create a startup task or use the IIS management APIs like is used here:

    http://blogs.msdn.com/b/tom/archive/2011/02/18/installing-and-using-an-httpmodule-in-windows-azure.aspx