Search code examples
.netasp.net-mvcglobal-asaxasp.net-mvc-areas

Get ASP.NET MVC area in Global.asax


Is there a way to get the ASP.NET MVC area in the global.asax, specficially the method below?

public override string GetVaryByCustomString(HttpContext context, string arg)
        {
            if (arg.ToLower() == "username" && context.User.Identity.IsAuthenticated) return context.User.Identity.Name;
       
            return base.GetVaryByCustomString(context, arg);
        }

Solution

  • Have you tried the solution found in this question/answer?

    HttpContext.Current.Request.RequestContext.RouteData.DataTokens["area"]