httpmodule

IIS7 Application Request Routing (arr reverse proxy) combined with managed module - time out

拜拜、爱过 提交于 2019-12-04 08:30:22
问题 I am trying to build a proxy that would serve requests to an internal site (hiding the origin) but at the same time inspect the packets and asynchronously post-process them. E.g. let's say all SOAP calls to http://www.foo.com will go to http://192.168.1.1, and at the same time be stored in a DB for post analysis. The internal server is a black box, so changing something on it is out of this question scope. Anyway, I have configured ARR, with reverse proxy, made URL rewrite filter with

Server.TransferRequest() and the http status code

人盡茶涼 提交于 2019-12-04 05:44:27
I had to implement a custom HttpModule to handle a 404 error in Sharepoint. It listens for the PreSendRequestContent event, and looks for a 404 status code. If one is found it does a TransferRequest. void App_PreSendRequestContent(object sender, EventArgs e) { HttpResponse res = App.Response; HttpRequest req = App.Request; if (res.StatusCode == 404 && !req.Url.AbsolutePath.Equals(PageNotFoundUrl, StringComparison.InvariantCultureIgnoreCase)) { App.Server.TransferRequest(PageNotFoundUrl); } } This works just fine, but I noticed in Fiddler that the page is showing a 200 status code, even though

Detecting if a HttpModule is loaded

耗尽温柔 提交于 2019-12-04 03:48:37
I'm trying to find a way to programmatically check if a particular HttpModule is loaded (as a component I'm writing requires the module to work correctly). I'm trying: bool ismodulepresent = false; foreach(HttpModuleAction module in ((HttpModulesSection)ConfigurationManager.GetSection("system.web/httpModules")).Modules) { if(module.Type == typeof(MyModule).FullName) { ismodulepresent = true; break; } } But that only works for the IIS5.1 <httpModules> section and not the newer <system.webServer> section. Any idea if there is a better way to do this other than just checking both sections?

Custom HttpModule for IIS 7 for integrated

荒凉一梦 提交于 2019-12-03 13:10:12
I'm having troubles with a custom Error handler I built. It should be a HttpModule , but when I add it to my web.config 's system.webServer/modules tag, it is not initiated. This is my web.config section: <system.webServer> <modules> <add name="AspExceptionHandler" type="Company.Exceptions.AspExceptionHandler, Company.Exceptions" preCondition="managedHandler" /> </modules> </system.webServer> This is the code in my HttpModule : using System; using System.Web; using Company.Settings; using System.Configuration; namespace Company.Exceptions { public class AspExceptionHandler : IHttpModule {

Can I be sure that HttpModules are executed in the order in which they are listed in the HttpApplication.Modules collection?

假如想象 提交于 2019-12-03 11:34:29
I want to write an IHttpModule that has to be executed strictly after FormsAuthenticationModule , otherwise it will be useless. There's HttpContext.Current.ApplicationInstance.Modules property that returns a collection of IHttpModule s. I can check that my module is after FormsAuthenticationModule in this collection. Will that be enough? Does that collection list IHttpModule s in the order in which they are executed? Recall that modules can subscribe to different pipeline events. Within any given pipeline event, modules should run in the order in which they're specified in the Modules

Processing static files via HttpModule in ASP.NET

眉间皱痕 提交于 2019-12-03 09:01:42
I have statiс files in website folder, but need to check permissions for every file. I decided to use HttpModule for that purposes. ASP.NET receives all the http-requests (I used wildcard mapping) and The algorith is the following: HttpModule receives the request HttpModule checks permissions If access is denied then the answer is "Forbidden". If all is OK then httpModule's method just returns. DefaultHttpHandler is automatically used to process request for static files The problem is that DefaultHttpHandler is not effective enough (it doesn't use file cache, etc.). But IIS (without ASP.NET)

Exception handling using an HttpModule

跟風遠走 提交于 2019-12-03 07:59:18
We're reviewing one of the company's system's exception handling and found a couple of interesting things. Most of the code blocks (if not all of them) are inside a try/catch block, and inside the catch block a new BaseApplicationException is being thrown - which seems to be coming from the Enterprise Libraries. I'm in a bit of a trouble here as I don't see the benefits off doing this. (throwing another exception anytime one occurs) One of the developers who's been using the system for a while said it's because that class's in charge of publishing the exception (sending emails and stuff like

How to protect application pools from session serialization exceptions?

五迷三道 提交于 2019-12-03 07:25:43
We're using an Out-of-Process Session Provider ( ScaleOut ) for an ASP.NET application and we've noticed that when an object that's not correctly setup for de-serialization inadvertently makes its way into session it will eventually cause the entire process to terminate . Reproducing and handling this scenario is where it gets even more interesting. The exception that terminates the process is raised in AnyStaObjectsInSessionState whose implementation is pretty straightforward: internal static bool AnyStaObjectsInSessionState(HttpSessionState session) { if (session != null) { int count =

IIS7 Application Request Routing (arr reverse proxy) combined with managed module - time out

独自空忆成欢 提交于 2019-12-03 00:49:34
I am trying to build a proxy that would serve requests to an internal site (hiding the origin) but at the same time inspect the packets and asynchronously post-process them. E.g. let's say all SOAP calls to http://www.foo.com will go to http://192.168.1.1 , and at the same time be stored in a DB for post analysis. The internal server is a black box, so changing something on it is out of this question scope. Anyway, I have configured ARR, with reverse proxy, made URL rewrite filter with wildcards, all works flawless. Then, I tried to add an managed HttpModule written in C#, and hooked to

Response.Redirect in HttpModule

最后都变了- 提交于 2019-12-02 02:34:53
问题 Can I do a redirect to a custom page in an HttpModule? I have an HttpModule A which executes some javascript code when any aspx page is loaded. I would like to have a server side code check to see if the clients browsers supports cookies. Can I place that code in the HttpModule A? If so, in which event? Or do I need to have a new HttpHandler for both purposes? Also, is it possible to check for cookies in an HttpModule(without a response.redirect)? All solutions I have seen need 2 pages, 1 for