In http module's BeginRequest event, how to find that current request is of MVC and not of traditoinal ASP.net ?
Asked
Active
Viewed 509 times
0
-
In HttpModules application.BeginRequest event, how can we find that the current request is Of MVC application? – SANTOSH AHER May 06 '13 at 13:02
-
The client's request will be a standard URL request in both cases. You would need to check the URL against MVC routes to see if it matches. It would probably be easiest to put your ASP.NET in a sub directory so that you can do a simple check against the request URL like `.Contains("example.com/aspsubdirectory")` so you know that is for the ASP.NET site. – AaronLS May 06 '13 at 13:05
-
ya that way its possible :), but if the server is loaded with many sites n there are thousands of users...in that case that would not be the great option. – SANTOSH AHER May 06 '13 at 13:08
-
Its possible in EndRequest Event, as we can check the current handler, that will be System.Web.Mvc.MvcHandeler .......but i need to check it in BeginRequest where the current handler is null. – SANTOSH AHER May 06 '13 at 13:10
1 Answers
0
What are you trying to accomplish? If you want some code to run prior to a particular controller action, or all actions of all controllers you can use action filters. These can be wired up using attributes on your controllers. Alternatively you can set them up dynamically using DI and interception, etc.
I think you're trying to do something in a way that is limiting your options... filters are most likely what you want.

BlakeH
- 3,354
- 2
- 21
- 31
-
No i dont want to execute any code prior to perticular controller and action, I want to execute some code if the current request is of MVC application. – SANTOSH AHER May 07 '13 at 06:36
-
Well good luck mate! You might have more responses and better results if you could describe why you want to intercept requests of an MVC application, but don't want to use the facilities provided by an MVC application (filters). – BlakeH May 07 '13 at 12:52