Questions tagged [httpmodule]

ASP.NET HTTP Modules are classes which implement the System.Web.IHttpModule interface.

819 questions
149
votes
8 answers

HTTP handler vs HTTP module

Can someone explain in less than 2 sentences the difference between both? Yes, I know google can provide hundreds of answers but not one in 2 clear sentences:)
frenchie
  • 46,331
  • 96
  • 283
  • 483
85
votes
5 answers

Can I access session state from an HTTPModule?

I could really do with updating a user's session variables from within my HTTPModule, but from what I can see, it isn't possible. UPDATE: My code is currently running inside the OnBeginRequest () event handler. UPDATE: Following advice received so…
Chris Roberts
  • 17,954
  • 11
  • 55
  • 66
81
votes
5 answers

IHttpHandler vs IHttpModule

My question is simple (although the answer will most likely not be): I'm trying to decide how to implement a server side upload handler in C# / ASP.NET. I've used both HttpModules (IHttpModule interface) and HttpHandlers (IHttpHandler interface)…
Dan Esparza
  • 26,944
  • 28
  • 97
  • 124
60
votes
3 answers

HTTPModule Event Execution Order?

Does anyone know of a site or page, or know the order of execution for the events of the HTTPApplication class for HTTPModule event execution? I found the MSDN Documentation for all of the events, but it doesn't show a list of process steps and I…
Adron
  • 2,331
  • 7
  • 25
  • 30
58
votes
1 answer

Why does my nested HttpModule EndRequest event handler not fire?

I'm having some strange behavior when I try to modify my headers with a EndRequest event handler in a nested HttpModule on MVC 5.2.2 and .NET 4.6.2. If I don't modify EndRequest in my top level HttpModule, it appears that the event handler in the…
Thomas Langston
  • 3,688
  • 1
  • 22
  • 36
49
votes
16 answers

Could not load file or assembly 'msshrtmi' or one of its dependencies (Azure Table Storage Access)

I have an HTTPModule that I use to redirect traffic between a website in my data center and a website running on the Azure platform. This HTTPModule retrieves its redirect rules from Azure Table Storage. Redirects work fine on my local dev machine…
William Edmondson
  • 3,519
  • 3
  • 29
  • 39
45
votes
5 answers

Programmatically register HttpModules at runtime

I'm writing an app where 3rd party vendors can write plugin DLLs and drop them into the web app's bin directory. I want the ability for these plugins to be able to register their own HttpModules if necessary. Is there anyway that I can add or…
jmcd
  • 4,062
  • 5
  • 32
  • 36
35
votes
2 answers

How is the order of execution for HttpModules determined?

Suppose that both FirstModule and SecondModule handle the Application_BeginRequest event. Will it execute in the order defined in the web.config?
jessegavin
  • 67,411
  • 26
  • 135
  • 162
34
votes
4 answers

HttpModule Init method is called several times - why?

I was creating a http module and while debugging I noticed something which at first (at least) seemed like weird behaviour. When I set a breakpoint in the init method of the httpmodule I can see that the http module init method is being called…
MartinF
  • 5,721
  • 5
  • 38
  • 28
32
votes
6 answers

How to log request inputstream with HttpModule, then reset InputStream position

I am trying to log the contents of an http request, using an IHttpModule like so: public class LoggingModule : IHttpModule { public void Init(HttpApplication context) { context.BeginRequest += ContextBeginRequest; } private…
cbp
  • 23,600
  • 27
  • 118
  • 194
29
votes
2 answers

How to dispose IHttpModule correctly?

All implementation of IHttpModule I've seen looks following: class HttpCompressionModule : IHttpModule { public void Init(HttpApplication application) { application.SomeEvent += OnSomeEvent; } private void OnSomeEvent(Object source,…
Jakub Šturc
  • 32,938
  • 24
  • 85
  • 107
27
votes
2 answers

Advanced: How many times does HttpModule Init() method get called during application's life?

Web application initialization is as follows: As we know when IIS receives the first request for a particular Asp.net application resource, IIS creates an instance of a HttpApplication (defined in global.asax codebehind). When this new instance is…
Robert Koritnik
  • 97,460
  • 50
  • 267
  • 388
22
votes
1 answer

HttpModule not called in .NET 4.5

Just spent a lot of time sifting through contradictory advice on this problem, and thought I'd post my solution. My environment is .NET 4.5, Visual Studio 2012, working on an MVC 4 application. I created an Http Module like I'd done in the past, and…
timprice
  • 321
  • 1
  • 2
  • 4
21
votes
3 answers

HttpModule not running with Visual Studio

I am using an HttpModule to do some URL shortening on my site. I am using Visual Studio 2008 and IIS 7, and .Net 3.5. When the module is specified in the system.webServer element of web.config, and the site is run in IIS, it works fine. The config…
Matt Sherman
  • 7,825
  • 4
  • 35
  • 55
21
votes
3 answers

HTTP module vs action filter in asp.net-mvc

I am developing an application in asp.net MVC3 and I have the following questions: When should I write an HTTP module and when should I write an action filter?
Martin
  • 745
  • 2
  • 7
  • 22
1
2 3
54 55