Application_BeginRequest
gets called when static files are served in my development using Visual Studio 2013. How can I stop Application_BeginRequest
from been called when serving static resources?
Asked
Active
Viewed 1,783 times
1

Alexei Levenkov
- 98,904
- 14
- 127
- 179

d0001
- 2,162
- 3
- 20
- 46
-
2You can't. You can add code in that blcok to only execute basedon the url requested, but you can't stop it from firing. – David Aug 19 '14 at 21:52
-
@DavidStratton - maybe Daniel asks for [runAllManagedModulesForAllRequests](http://stackoverflow.com/questions/11048863/modules-runallmanagedmodulesforallrequests-true-meaning)? OR maybe something else... not exactly clear what "static files" mean. – Alexei Levenkov Aug 19 '14 at 21:56
-
Static files would be things like images, etc. Items that are not code/dynamic like aspx, ashx, asmx, etc. – David Aug 19 '14 at 21:58
-
@DavidStratton can you show me an example on how to filter those requests? – d0001 Aug 19 '14 at 22:03
-
possible duplicate of [Prevent IIS from serving static files through ASP.NET pipeline](http://stackoverflow.com/questions/6279643/prevent-iis-from-serving-static-files-through-asp-net-pipeline) – UserControl Aug 20 '14 at 20:51
-
@UserControl Solution did not work for MVC5. – d0001 Aug 20 '14 at 21:14
-
Can you add the content of `system.webServer/modules` section to your post? It may help. – UserControl Aug 20 '14 at 21:16
1 Answers
1
For me the solution was in Web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="false" />
</system.webServer>

Aurelio Jaraiz
- 71
- 1
- 3