我有一个 WCF 数据服务作为 Azure Web 角色托管在 Azure 中。添加了用于身份验证的 Http 模块。自定义 Http 模块查看请求标头中的授权标头并对用户进行身份验证。
当我向 WCF 数据服务发出 Http 请求时,遇到两个问题。发生 Http 重定向。
我向 http:\northwindsample.cloudapp.net\SampleService.svc 发出请求。我收到的消息是“没有操作监听 http://rd00155d341b52/SampleService.svc,但是有是监听 http://northwindsample.cloudapp.net/SampleService.svc/,因此您将被重定向到那里。
虽然我向 http:\northwindsample.cloudapp.net\SampleService.svc 发出请求,但它不知何故会转到 http:// rd00155d341b52/SampleService.svc,然后重定向到实际服务。我收到 Http 307,并且在重定向中缺少授权标头。
后来我发现当我添加尾部斜杠时,就没有发生重定向。
由于缺少尾部斜杠,如何防止这种重定向?还有一个问题是授权标头不会发送到重定向的 Uri。
谢谢
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
发布评论
评论(1)
看看这个:
http: //gavinmckay.wordpress.com/2009/03/24/howto-fix-wcf-host-name-on-iis/
要在 Azure 中更新此内容,您需要创建一个启动任务或使用 IIS 管理 API,如下所示:
http://blogs.msdn.com/b/tom/archive/2011/02/18/installing-and-using-an-httpmodule-in-windows-azure.aspx
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