ihttpmodule

Is ReleaseRequestState called multiple times for each Request received by IIS?

坚强是说给别人听的谎言 提交于 2020-01-15 14:16:24
问题 I am writing an HttpModule in VS2010/ASP.NET 4.0 for use with IIS 7. The module is going to enforce query string security by encrypting query strings. I would like this module to be completely independent of as well as transparent to the website, so that the website has no knowledge of the fact that query string encryption is being employed. This will ensure firstly that pages/controls don't have to care about this issue. Secondly, it would enable query string encryption for Production

Accessing context session variables in c#

二次信任 提交于 2019-12-25 02:50:18
问题 I have an ASP.NET application and dll which extends IHttpModule. I have used the below method to save the session variables in httpcontext through public class Handler : IHttpModule,IRequiresSessionState { public void Init(HttpApplication httpApp) { httpApp.PreRequestHandlerExecute += new EventHandler(PreRequestHandlerExecute); } public void PreRequestHandlerExecute(object sender, EventArgs e) { var context = ((HttpApplication)sender).Context; context.Session["myvariable"] = "Gowtham"; } }

IHttpModule behaves differently on different servers

安稳与你 提交于 2019-12-24 03:42:54
问题 I'm developing an application and I'm debugging the code with Visual Studio 2013 and Visual Studio 2010 and the code behaves differently with the two programs. In VS 2010, after the code behind has been executed and the page has been built, the execution ends. In VS 2013, after the page has been built, it gets fired another call to the method context_BeginRequest(object sender, EventArgs e) in IHttpModule, which I have implemented. First problem is: why is there this additional call? Second

json ihttpmodule compression

谁说我不能喝 提交于 2019-12-08 08:28:24
问题 I wrote an IHttpModule that compress my respone using gzip (I return a lot of data) in order to reduce response size. It is working great as long as the web service doesn't throws an exception. In case exception is thrown, the exception gzipped but the Content-encoding header is disappear and the client doesn't know to read the exception. How can I solve this? Why the header is missing? I need to get the exception in the client. Here is the module: public class JsonCompressionModule :

Inject js from IhttpModule

早过忘川 提交于 2019-12-04 11:30:14
问题 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" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Temp</title> </head> <body> <form id="form1"> <div> </div> </form> </body> </html> the

Inject js from IhttpModule

↘锁芯ラ 提交于 2019-12-03 08:11:39
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" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Temp</title> </head> <body> <form id="form1"> <div> </div> </form> </body> </html> the ihttpmodule: public class MyExtensionModule : IHttpModule { #region IHttpModule Members public void Dispose() { }

Logging raw and compressed HTTP responses in ASP.NET & IIS7

非 Y 不嫁゛ 提交于 2019-12-01 09:27:51
Along the lines of this question I want to create a HttpModule that will do some custom logging of requests and responses for us. Using the code in the most popular answer for that question I've got a HttpModule up and running which does indeed work: class PortalTrafficModule : IHttpModule { public void Dispose() { // Do Nothing } public void Init(HttpApplication context) { context.BeginRequest += new EventHandler(context_BeginRequest); context.EndRequest += new EventHandler(context_EndRequest); } private void context_BeginRequest(object sender, EventArgs e) { HttpContext context = (

Logging raw and compressed HTTP responses in ASP.NET & IIS7

烈酒焚心 提交于 2019-12-01 07:11:49
问题 Along the lines of this question I want to create a HttpModule that will do some custom logging of requests and responses for us. Using the code in the most popular answer for that question I've got a HttpModule up and running which does indeed work: class PortalTrafficModule : IHttpModule { public void Dispose() { // Do Nothing } public void Init(HttpApplication context) { context.BeginRequest += new EventHandler(context_BeginRequest); context.EndRequest += new EventHandler(context

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

谁说胖子不能爱 提交于 2019-11-30 12:53:52
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 filesystem? For example: public class MyModule:IHttpModule { public void Dispose(){ } public void Init(HttpApplication context) { context.BeginRequest += (o, e) => Debug.Print("Request: " + HttpContext.Current.Request.RawUrl); } } And I declare it this way: <modules runAllManagedModulesForAllRequests="true"> <add name="MyModule" preCondition="managedHandler"