Questions tagged [ihttpmodule]

121 questions
153
votes
15 answers

Logging raw HTTP request/response in ASP.NET MVC & IIS7

I'm writing a web service (using ASP.NET MVC) and for support purposes we'd like to be able to log the requests and response in as close as possible to the raw, on-the-wire format (i.e including HTTP method, path, all headers, and the body) into a…
Greg Beech
  • 133,383
  • 43
  • 204
  • 250
10
votes
5 answers

Requests for static files are hitting the managed code in ASP.NET MVC3

Creating custom IHttpModules, I have realized that the requests for static files (e.g.: .css and .js files) are hitting the managed modules. Probably pictures have the same problem. Shouldn't IIS bypass ASP.NET for files that exists in the…
vtortola
  • 34,709
  • 29
  • 161
  • 263
8
votes
1 answer

How to store global per request data in a .NET Web API project

I am working on writing a web api for my application that is currently written using ASP.NET Web Forms. I have a module that acquires some data at the beginning of the request and stores it in HttpContext.Current.Items so that it is available to…
Leslie Hanks
  • 2,347
  • 3
  • 31
  • 42
7
votes
1 answer

Inject js from IhttpModule

i trying to inject js to page (to tags) by using ihttpmodule. but js isn't injected. what i did: the page: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyTempProject._Default" %>
David Michaeli
  • 777
  • 4
  • 11
  • 22
7
votes
4 answers

Is HttpModule shared among working threads?

Do I have to lock access to instance members? Example: public class HttpModule : IHttpModule { //... Dictionary foo; void UseFoo(int a, int b) { foo[a] = b; } }
TN.
  • 18,874
  • 30
  • 99
  • 157
5
votes
3 answers

Disabling HttpModule on certain location

I know that this has already been asked here but the answer (using a handler instead) doesn't solve the issue, as I'm using a third party component that doesn't implement IHttpHandler. So, again, is there any way to load/unload a HttpModule on a…
MaLKaV_eS
  • 1,325
  • 3
  • 23
  • 39
5
votes
2 answers

Using IHttpModule Over Global.asax

I've been given the thrilling task of re-writing our exception handling system. Whilst I will state that handling exceptions from an application-wide point of view isn't something we want, typically it's unavoidable when our team are understaffed…
Kieran Senior
  • 17,960
  • 26
  • 94
  • 138
5
votes
2 answers

Invalid URI: The hostname could not be parsed via our custom rewrite IHttpModule

This is a strange error we're seeing sporadically on our website. The strange thing about this error is it's being thrown in our URL rewritting IHttpModule. The line in question is: var host = context.Request.Url.Host; If I record…
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
5
votes
3 answers

What is better: caching through HttpContext.Current.Cache or just a static?

Last night I wrote up my first IHttpModule to do some request processing. I'm using a regular expression to inspect the raw url. The IHttpModule will be called on every request, so it seems reasonable to do some sort of caching of the regular…
Kees C. Bakker
  • 32,294
  • 27
  • 115
  • 203
5
votes
2 answers

JS,Images and CSS getting intercepted by HTTPModule

I have a simple HTTPModule which does some custom session state management. public void Init(HttpApplication context) { context.AcquireRequestState += new EventHandler(ProcessBeginRequest); ActivityLogger.LogInfo(…
ram
  • 11,468
  • 16
  • 63
  • 89
4
votes
1 answer

Why is there no way to unbind an HttpApplication event handler out of IHttpModule initialization scope

Let's say we want to execute some action only once or a couple of times after web application has started and during a web request. public class WebApp : HttpApplication { public override void Init() { base.Init(); …
Konstantin Tarkus
  • 37,618
  • 14
  • 135
  • 121
4
votes
1 answer

How to register http module in IIS 10

I want to register my custom http module in web.config file. When I register under system.webServer section But it didn't run into http module in visual studio 2015. The madn seems just introduce it how to register in iis6,iis7.…
user5631512
  • 41
  • 1
  • 4
4
votes
1 answer

How to handle Compressed Request in WCF REST service

We have a WCF REST service hosted on IIS 7 with .NET Framework 4.5. The client is sending data in GZip compressed format with request headers: Content-Encoding:gzip Content-Type: application/xml But we are getting bad request from the server, if…
neo
  • 6,131
  • 6
  • 22
  • 27
4
votes
1 answer

Limiting HttpModule to only process certain requests

We use directory browsing on a specific section of our website, but our users don't really like the default ASP.NET directory browsing. To be honest, we don't particularly care for it either. I came across mvolo's custom directory browsing module…
Jeremy
  • 169
  • 1
  • 2
  • 10
3
votes
3 answers

Can I intercept after a response has been sent to a client in an IHttpModule

I have a custom IHttpModule that is used to log all HTTP requests and responses, and this is currently working very well, but I'd love to extend it so I can determine how long a response actually takes. The response is logged in the…
Cleggy
  • 715
  • 9
  • 24
1
2 3
8 9