asp.net authentication on Windows Azure
I have put my web application as an web role in a Azure service so I can deploy it on Azure. It works perfect, but I have one problem.
I use an HttpModule for url rewriting and have no .aspx endings. So "/Messages" -> "/Messages.aspx". For some reason the authentication doesn't work when I do this. HttpContext.Current.User comes out as null in the HttpModule and the global.a开发者_开发百科sax Application_AuthenticateRequest is never fired. This works with the .aspx endings, but not without. The rewriter works, but when the request gets to the original .aspx page the user is not logged in.
Can anyone help me with this?
I use forms authentication, by the way.
I don't think this has anything to do with Azure.
It looks like this is a common problem, e.g. see questions like:
- 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
Looking at these, one common element is the UrlRewriter
open source module - it seems like this has a few problems which seem to be based near the BeginRequest
and AuthorizeRequest
events.
Can you confirm which rewriter you are using? Can you post any code about what events that rewriter is hooking into?
Can you use the official rewrite module? http://msdn.microsoft.com/en-us/library/dd573358.aspx
精彩评论