Last active
September 30, 2023 18:02
-
-
Save halityurttas/e8713a1ccaf6f7dd7563 to your computer and use it in GitHub Desktop.
Get current controller and action name in global.asax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Application_BeginRequest(object sender, EventArgs e) | |
{ | |
HttpContextBase context = new HttpContextWrapper(HttpContext.Current); | |
RouteData rd = RouteTable.Routes.GetRouteData(context); | |
if (rd != null) | |
{ | |
string controllerName = rd.GetRequiredString("controller"); | |
string actionName = rd.GetRequiredString("action"); | |
Response.Write("c:" + controllerName + " a:" + actionName); | |
Response.End(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Worked, thanks :)