httpmodule

IoC Dependency injection into Custom HTTP Module - how? (ASP.NET)

…衆ロ難τιáo~ 提交于 2019-11-29 03:57:36
I have a custom HTTP Module. I would like to inject the logger using my IoC framework, so I can log errors in the module. However, of course I don't get a constructor, so can't inject it into that. What's the best way to go about this? If you need the specific IoC container - I'm currently using Windsor, but may soon move to AutoFac. Thanks Mauricio Scheffer I just answered this question on my blog . See also http://lozanotek.com/blog/archive/2009/08/19/Autowire_IHttpModules_with_IoC.aspx First time I saw dependency injection to HttpModules in Spring.NET (not advertising this framework though)

How do I retrieve response html from within a HttpModule?

爱⌒轻易说出口 提交于 2019-11-29 03:00:03
问题 Here is what I'm specifically trying to do: I have written a HttpModule to do some site specific tracking. Some old .aspx pages on our site are hard coded with no real controls, but they are .aspx files so my module still runs when they are requested. My module's handler is attached to the PostRequestHandlerExecute, so I believe what will be sent back to the requester should have already been determined. I need to be able to extract whatever string is in the title tag. So if <title>Chunky

HttpModule Init method is called several times - why?

拜拜、爱过 提交于 2019-11-29 02:15:37
问题 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 several times even though i have only started up the website for debugging and made one single request (sometimes it is hit only 1 time, other times as many as 10 times). I know that I should expect several instances of the HttpApplication to be running

Hook into Application_Start in a HttpModule

爷,独闯天下 提交于 2019-11-29 02:00:26
I’m implementing a simple HttpModule, where I want some code to run when the web application is started. But I’m surprised to find that the Application_Start event I would normally use from Global.asax is not available from a HttpModule. Is that correct, or am I missing something here? How do I hook into the Application_Start event from an HttpModule? Update: I’ve come to simple solution using the Init event instead, but it still smells a bit funny to me. You CAN use HttpModule to handle application start event Contrary to others that only write/believe what they read I've done my own part and

BUG: IIS7 managed requests

大兔子大兔子 提交于 2019-11-29 01:15:17
问题 ( I don't know whether should I also post this question to ServerFault, since it's about IIS configuration? ) In IIS7 we can tell a module to run for managed content (thus speeding up static content serving) by: <modules> ... <add name="WhateverName" type="WhateverType" preCondition="managedHandler" ... </modules> But. This works fine and dandy as long as there's also a file name (with extension) in the requested URL. If it's omitted it IIS7 will think you want static content and managed

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

时光总嘲笑我的痴心妄想 提交于 2019-11-28 17:10:59
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 as well as when running on Azure. However, when I deploy the module to my data center servers ( IIS 7, WS 2008 R2 Standard 64bit, .NET 4.0, ASP.NET 4.0 ) I receive the following error Parser Error Message: Could not load file or assembly 'msshrtmi' or one of its dependencies. An attempt was made to load a program with an incorrect format. Line 124:

What are some best practices for managing background threads in IIS?

北城以北 提交于 2019-11-28 10:01:47
I have written an HttpModule that spawns a background thread. I'm using the thread like a Scheduled Task that runs in-process, which is really handy. What are best practices for keeping track of this thread? I've never done this before, and I'm a little confused about some aspects of it: How do I know if the thread is still running? I see it do its job, but is there another way to know if it's still alive? I downloaded ProcMon, but w3wp.exe spawns a boatload of threads, so I had no idea which was my thread. I named it, but that didn't help. How do I "catch" the thread if it dies? Is there some

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

时间秒杀一切 提交于 2019-11-28 08:55:59
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 void ContextBeginRequest(object sender, EventArgs e) { var request = ((HttpApplication)sender).Request; string content; using (var reader = new StreamReader(request.InputStream)) { content = reader.ReadToEnd(); } LogRequest(content) } } The problem is that after reading the input stream to the end, the InputStream seems to have either disappeared or more likely, the cursor

RoleProvider dosn't work with custom IIdentity and IPrincipal on server

两盒软妹~` 提交于 2019-11-28 04:35:33
问题 I'm using a custom IIdentity and IPrincipal in my ASP.NET MVC application via EF 4.3 as expalined here (and follow accepted answer's solution). Also, I have a custom RoleProvider . In local (using IIS Express ), it works currectly . But now, when I upload the application on a real host, it seems all users are in "admin" role! e.g. I create a user that is not in role "admin" , but it can access to all protected pages (that need "admin" role). e.g. Role.IsUserInRole always returns true . Have

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

不羁的心 提交于 2019-11-28 04:09:42
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 created it's initialization happens that also checks all configured HTTP modules. All modules are then instantiated and put in the application's Modules collection (of type HttpModuleCollection ) modules are looped through and their Init() method is called (when they register for request events) As far as I understand it the above scenario happens