My ASP.NET MVC intranet app has a data repository that uses current user’s Windows login to retrieve data that belongs to the user’s default home site. The login contains a site identifier. The repository class is the only place that accesses the HttpContext.Current.User.Identity and extracts the site id from the login. Therefore, the application only serves one user site’s data. Now our requirements have changed that users can view other sites’ data by clicking a different site name link from a Site menu. The Site menu is in the Master page. When the user clicks on any site link, the site scope needs to be updated then it re-executes the action that was executed before the site link is clicked with the new site scope. For example, if a user executes Requests List, by default it will show only the requests from the user’s default site. When the user clicks another site, it will show t hat site’s requests. There are many controller actions in the app, I prefer not modifying each action of each controller and existing routes. I am thinking about creating a new controller with an action to set the Site scope, but I don’t know how to make it aware what action was executed before the new controller’s action is executed. Should I use Session variable to keep the scope change? Is an Action Filter a better way to re-factor my app? Any suggestion with code sample is appreciated. Thank you.
My ASP.NET MVC intranet app has a data repository that uses current user’s Windows
Share
I ended up creating a new controller with an action to create a session variable after which a redirect is executed. In the Repository, the session variable is checked to see if it is the same as the user’s home site. The session variable’s value is return if they are different scope. The Index.aspx of the SiteController.Index() return a UserControl.