How to detect that incoming request is for MVC controller or API controller through HttpApplication?
Asked
Active
Viewed 475 times
1 Answers
1
There are different ways to achieve what you want. Assuming you´re working with ASP.NET MVC 4+ you could use:
Application_BeginRequest()
You can register this Event in your Global.asax.cs
For example you could access your request like so:
protected void Application_BeginRequest(object sender, EventArgs e)
{
//Perform actions on HttpContext.Current.Request
}
You can find a pretty nice overview on this event here (DotNetPerls Example).
Another possible solution would be a GlobalFilter. This was already answered many times and you can get further information Here (Stack Overflow Answer).
It depends on your use case what version you would prefer.

Community
- 1
- 1

Stefan Kert
- 587
- 4
- 9