Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6906283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:17:24+00:00 2026-05-27T08:17:24+00:00

My ASP.NET MVC intranet app has a data repository that uses current user’s Windows

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:17:25+00:00Added an answer on May 27, 2026 at 8:17 am

    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.

    <%@ Control Language="C#"    Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<VETS.Models.Site>>" %>
    <ul id="menu">
        <% foreach (var item in Model)
           { %>
    
        <li><%: Html.ActionLink(item.SiteName, "SetSiteScope", new { siteID = item.SiteID })%></li>
        <%
           } %>
    </ul>
    
    public class SiteController : Controller 
    {
        public ActionResult SetSiteScope(short siteID)
        {
            HttpContext.Session.Add("CurrentSiteID",siteID);
            //var routeData = ControllerContext.RouteData;
            //routeData.Route.ToString();
            //var actionName = ControllerContext.RouteData.GetRequiredString("action");
            //return RedirectToAction(actionName, "Transfers");
            Uri prevURL = HttpContext.Request.UrlReferrer;
            return Redirect(prevURL.ToString());
        }
    }
    
    public class vRepository : IvRepository
    {
        public Site CurrentSite()
        {
    
          if (HttpContext.Current.Session != null && HttpContext.Current.Session["CurrentSiteID"] != null)
          {
            targetSiteID = short.Parse(HttpContext.Current.Session["CurrentSiteID"].ToString());
            targetSite = SiteList().Single(s => s.SiteID == targetSiteID);
          }
          return targetSite;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.Net MVC intranet site which uses Windows Authentication to know who
My team has a new Asp.net MVC intranet app. I have been doing some
I'm creating an intranet asp.net mvc application that everyone in the company should have
ASP.NET MVC web app that exposes friendly URLs: http://somesite.com/friendlyurl ...which are rewritten (not redirected)
I have asp.net mvc intranet site that is deployed to IIS6. Site is used
How can I implement following in ASP.NET MVC application: user opens intranet website user
i have an intranet app asp.net mvc site. is there anyway to capture the
In an ASP.NET MVC 3.0 application (intranet), the end user is logged on the
ASP.NET MVC has been discussed on this forum a few times. I'm about to
I have an asp.net mvc 2 web application that connects to a WCF web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.