authentication - Displaying same content to different users who may be seeing different master pages (ASP.net) -
I have some pages that are relevant to both logged in users and non logged users. For example, all pages of contact information, privacy policies, etc. You have a typical navigation menu on all pages, but there is a separate navigation menu bar that is not logged in normally logged on by the users logged in.
What is the best way to do this in ASP.net?
So far, potential solutions include the following:
- Displaying the content using the pop-up window will not contain any menu and just some original page No need to see which types of users are watching it
- Changing the master page is programmatic, depending on whether the user is certified or not. However, there are some variables on some of these master pages that need to be accessed but not touched by unreliable users at all.
- Two different pages to insert content into user control and display this user control to the appropriate user.
I'm not really a fan of # 1 because users who come to the site for the first time may have some kind of popup blocker or JavaScript is disabled
I know That is possible by using some kind of base class on page 2 that is inherited from the masterpiece. However, I have read that this may not be the best design because now any one of the pages has access to variables which is not really necessary.
The third method seems fair but then two separate ASPX files.
Is there a proper way to do this? Or another way I have not thought so far?
Edit
To clarify, logged users need to set some variables in their master pages where non-logged users do not The reason is that there is a user control that shows a specific navigation menu that will highlight some objects based on these variables. For example, user control requires a string to determine which item to highlight. The page with profile information will provide the "parameter" as a parameter that will highlight the "profile" item on the menu.
In the user control, the menu is dynamically generated based on the data from the database. Menu items are classified by category and displayed with an appropriate title which is also drawn from DB.
Change the master page program is easy; Just supply the correct URL on the pre init, set
Secure Override Zero OnPreInit (..) {If (this.User! = Null) {If (this.User.Identity.IsAuthenticated ) This .masterpage_file = "~ / loggedin.master"; And this.masters pagefile = "~ / notloggedin.master"; }} No Base Class is required for this.
The user control approach will also work, but changing the master page file is really easy to do.
EDIT: If you have the property to set or receive from the owner, then you may have code-behind file to implement the interface, and can check that it What is the master reference to that interface type.
HTH
Comments
Post a Comment