How to get file name of any page regardless of URL?
I would like to force SSL on certain pages around the site, like for login, registration etc. by specifying a string array and checking whether the current URL fits a certain criteria in a custom HttpModule. It works well, as long as the URL correctly reflects the page, however I use routing tables, so some requests I point to 开发者_运维问答login page, if a page requires login, and I end up with a login page on the screen and with an URL for members' area. Is there a way to find the actual file name of a page?
Example:
http://www.mysite.com/login - file name is login.aspx, which is not reflected by the url. http://www.mysite.com/members - file name is still login.aspx if a user is not logged in.Instead of using the URL, could you use the class name?
If TypeOf(Page) Is LoginPage Then
End If
System.IO.Path.GetFileName(HttpContext.Current.Request.FilePath);
精彩评论