开发者

ASP.NET Master page Page_Load Override

开发者 https://www.devze.com 2022-12-18 05:26 出处:网络
I have a Master page for my site that is used for styling the rest of the site and doing user authentication. This works fine except that I h开发者_StackOverflow中文版ave one page that I would like to

I have a Master page for my site that is used for styling the rest of the site and doing user authentication. This works fine except that I h开发者_StackOverflow中文版ave one page that I would like to retain the styling from the master but not do the authentication since this is the page that tells the user that they aren't authenticated. How could I override the MasterPage's Page_Load method from this one page? Any other thoughts on how I could not authenticate on this one page without moving authentication from the master?


Maybe check in your master page somewhere in Request.Current.Url for the current page name (Whatever.aspx) and skip authentication for it.


You can create a property on your master page that defaults to true, meaning that authenitcation should happen. You can then set that property inside of the initialization logic for the single page to false. When the master page tries to do authentication, it should first check for the state of this property.

For an example of how to communicate with a master page like this, take a look at the Abstract Interaction section of this article.


Detecting page by using Request.Current.Url is a good solution.

Another way is to use LoginView which has LoggedInTemplate, AnonymousTemplate and roles support for content viewing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号