简体   繁体   中英

how to create a general HttpContext.Current.User.Identity.IsAuthenticated validation?

First of, i'm a noob with aspx and visual studio. i've created an web project that is part of another project developed by someone else. I need to do an integration of my project with the functionality of the other one. One functionality is the user session, In my project i don't include a session management because it's already managed in the other application but since now i need to integrate both, i noticed that the other project include in every aspx file (in the Page_Load of Code behind) the next code:

If HttpContext.Current.User.Identity.IsAuthenticated = False Then
.
.
.
End If

Since i don't include that code in my project, now i need to include it. My question is: there is another way to include that code without modify all my aspx file? My first thought was include that line in the master page, but since the master page run after the content page, i don't think that is a good option.

The project is in vb.net but if the solution is in c# i can try to translate the code.

I found a good solution. I've created a new class with the role of being the base for every new webform.

The new class Inherits System.Web.UI.Page, and i'm using the Page_PreInit to verify the session. and now every existing webform in the project Inherits from the new class. The validation is always executed and the amount of code modified was little

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM