Azure WebRole 和 WCF 数据服务 - 防止重定向

发布于 2025-01-03 21:58:43 字数 833 浏览 5 评论 0 原文

我有一个 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半枫 2025-01-10 21:58:43

看看这个:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文