c# - MVC5 Calling function on MapRoute -
In our site we are doing something like "GodMode", when this mode is enabled, we want data Display data differently For regular public websites, for example, if a user visits,
http: // domain / home / index
He'll see the regular public page But if in the same browser / session, go to
http: // domain / godmode / home / index
then we want to show other information . For this, I will create a static boolean variable that I set to set the wish
when we will find out that is the godmode
, so I see a way to do this I am here. Any idea how can I set this variable? Or what is the best place to set it, so both URLs can run in the same session without interrupting each other.
I know that for the Global.asax application level in the Application_BeginRequest
, url request is not requested, I did not get any relevant replacement for it. Can someone please give a suggestion or if we can call the function in MVC MapRoute
function?
What about an action filter? I use them to switch languages like this:
public class internationalization attribution: ActionFilterAetabet {/// & lt; Summary & gt; /// Logger /// & lt; / Summary & gt; Private nolog Logger logger; Private NLog.Logger Logger {get (if.logger == zero) {this.logger = NLog.LogManager.GetCurrentClassLogger (); } Return to this. Logger; }} /// & lt; Summary & gt; /// A method is executed before the ASP.net framework is executed with the /// & lt; / Summary & gt; /// & lt; Param name = "filterContext" & gt; Filter Reference. & Lt; / Param & gt; Public override zero OnActionExecuting {string language = (string) filterContext.RouteData.Values ["language"] ?? "De"; String culture = (string) filterContext.RouteData.Values ["culture"] ?? "De"; Try {Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo (string.Format ("{0} - {1}", language, culture)); Thread Present. culture. Culture = cultureInfoGateCultureInfo (string format ("{0} - {1}", language, culture)); } Grip (Exceptional) {//// is not a supported culture, it is falling to the default. Loger Error (string.Format ("Invalid culture '{0} - {1}', can not be set '', language, culture), prior);}}}}
And in the Maproute function:
Route MapRoute ("DefaultLocalizedQuestionManagementArea", "{language} - {culture} / {controller}} .aspx / {action} / {id}", new { In the end, each controller is a stoop: "Controller =" home ", action =" index ", id = string.Empty, language =" de ", culture =" DE "});
Is prefixed with such a specialty:
[internationalization attribute] public class Account Controller: Controller {}
Comments
Post a Comment