我已将我的 Web 应用程序作为 Azure 服务中的 Web 角色,以便可以将其部署在 Azure 上。它工作完美,但我有一个问题。
我使用 HttpModule 进行 url 重写,并且没有 .aspx 结尾。所以“/Messages”->“/Messages.aspx”。由于某种原因,当我这样做时,身份验证不起作用。 HttpContext.Current.User 在 HttpModule 中显示为 null,并且 global.asax Application_AuthenticateRequest 永远不会被触发。这适用于 .aspx 结尾,但也适用。重写器可以工作,但是当请求到达原始 .aspx 页面时,用户尚未登录。
谁能帮我解决这个问题吗?
顺便说一句,我使用表单例份验证。
最佳答案
我认为这与 Azure 没有任何关系。
看起来这是一个常见问题,例如查看如下问题:
- ASP.Net URL rewriting and authentication
- Using Forms Authentication/Authorization with Rewritten URLs
- http://www.velocityreviews.com/forums/t103352-url-rewriting-with-forms-authentication.html
- http://forums.iis.net/t/1165592.aspx
- https://stackoverflow.com/questions/3675314/how-should-iis7-authentication-work-with-the-url-rewrite-module
看看这些,一个常见的元素是 UrlRewriter
开源模块 - 看起来这有一些问题,这些问题似乎基于 BeginRequest
和 >AuthorizeRequest
事件。
您能确认您使用的是哪个重写器吗?您可以发布有关重写器 Hook 的事件的任何代码吗?
可以使用官方的重写模块吗? http://msdn.microsoft.com/en-us/library/dd573358.aspx
关于Windows Azure 上的 asp.net 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6277451/