httpmodule

ASP.NET: HttpModule

How can I check what content has been sent by or buffered into a Response in my HttpModule? ...

ASP.NET: Legitimate architecture/HttpModule concern?

An architect at my work recently read Yahoo!'s Exceptional Performance Best Practices guide where it says to use a far-future Expires header for resources used by a page such as JavaScript, CSS, and images. The idea is you set a Expires header for these resources years into the future so they're always cached by the browser, and whenever...

HTTPModule BeginRequest should us Response.Redirect or Server.Transfer

We have a URLRewriting module that is using a Response.Redirect in the BeginRequest event method to change the destination page. Would it be better to use Server.Transfer or Server.TransferRequest instead of Response.Redirect? There are other HTTP Modules in the solution, will I bypass any of the other modules by using Server.Transfe...

How do you get the default document in an http module?

I am working on an HttpModule which does a number of things. Long story short, I simply would like to be able to determine what is the default document and do a context.RewritePath to it. Any suggestions? :) ...

Dynamic Pages From a Database in C#

Forgive me if this has already been asked somewhere, but I cannot figure out the best way to accomplish this task. I want to be able to create a rendering system that will allow me to render out content from thousands of different .aspx pages without having to create thousands of .aspx pages. That being said, I still want to be able to r...

HttpModule for a Response Filter - override Write or Close

What are the advantages/disadvantages of overriding Write instead of Close on the Filter Stream that does filtering in an HttpModule? I assume you would want to use Write because the memory used by the buffer is smaller than using the entire byte array during Close. Are there other reasons not to do manipulation in Close? ...

Why would AcquireRequestState in my HTTPModule not fire _sometimes_?

I've got an HTTPModule that does some role-based page access security (I'm having to retrofit some security into some code that we've acquired). I've noticed that in one instance that it doesn't fire on a Server.Transfer. Here's a snippet of the code: ' move to target page Select Case eTransferMethod Case TargetPag...

Determining Page of current Url in an HttpModule

I suspect the answer is no (or at least, not in an intelligent manner), but felt like asking. Is it possible in an asp.net HttpModule to determine the page that is going to be returned to the user, taking default page settings of IIS into account (without hardcoding them outside of IIS). For example, if a user requests http://www.examp...

Removing the Transfer-Encoding response header for certain responses in IIS7

I am trying to write an IIS Http Module that requires strict control of the response headers. I am currently using an Event Handler for PreSendRequestHeaders to remove headers I don't want and add headers I do, but I am unable to remove the Transfer-Encoding header that IIS seems to insist on adding (as the first header as well) and app...

HttpModule AcquireRequestState event handler has null sender

I have an HttpModule, something like this: public class MyModule : IHttpModule { public void Init(HttpApplication context) { context.AcquireRequestState += Context_OnAcquireRequestState; } private void Context_OnAcquireRequestState(object sender, EventArgs e) { HttpContext context = ((HttpApplication)se...

ASP.NET: require login based on netmask

I need to secure access to all pages in a .NET webapp - EXCEPT requests from: local network (the network IIS is running on) IPs listed/netmasks listed in a database all other requesets should be redirected to a login form I was thinking in the direction of a HttpModule - but never wrote one. Can anyone provide any ideas to this? Th...

asp.net file downloading - track downloaded size

I am trying to design a system for something like this with ASP.net/C#. The users pay for downloading some content (files- mp3s/PDFs,doc etc).I should be able to track the number of bytes downloaded by the user. If the number of bytes downloaded match the number of bytes on the server, I should set a flag in DB (telling that the downloa...

ISAPI vs httphandler

In IIS6 was there a reason for using ISAPI filters/ extensions?. Can the same not be achieved using httphandler/ http modules. Also in IIS7 has ISAPI been removed completely ?. Is the entire code of IIS7 written in .Net. I want to know should one know about ISAPI in detail for debugging or adding new features ? ...

HttpContext.Current.CurrentHandler is NULL in ReleaseRequestState eventHandler

I have a module with custom ReleaseRequestState eventHandler. In this eventHandler i use HttpContext.Current.CurrentHandler, and just now revealed that in some situations (particularly - for *.css files) it can be NULL. How this can be, and how it can be correctly workarounded? ...

Using custom httpmodule and have 'Sys' is undefined errors.

I have created my own custom httpmodule to handle url rewriting so that urls like www.contoso.com/help/default.aspx will point to www.contoso.com/default.aspx where the actual resource is located. This works fine, but because of my implementation of an httpmodule I am having problems with ScriptResource.axd not being run properly to add...

What is the Java equivalent to ASP.NET Http Modules?

Hi all, I'm considering rewriting a small Http Module i made in ASP.NET in Java. Based on a specific URL, the Http Module inserts some HTML on an empty HTML layout, do some basic reformatting, and finally returns the rendered HTML. Being new to Java web development, what is the equivalent to ASP.NET Http Modules? ...

HTTPModule and Sharepoint Site

Hello All, I am running into an issue with using a HTTPModule with a sharepoint deployed site. Here is what I have: my asp.net pages inside the /layouts/[ProjectName]/ folder. The aspx file uses a sharepoint masterpage i have a HTTPModule and implments IHTTPModule the web.config contains {httpModules} {add name="HTTPModule" type="H...

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( DateTime.UtcNow.ToLongTimeString() + " In Init " + HttpContext.Current.Request.Url.AbsoluteU...

EndRequest not fired on IIS when resource is missing.

I have a HttpModule that hooks on the EndRequest Event on a IIS6 with a wildcard handler registered and it works fine as long as the request ends on a .aspx page, but NOT if the url is missing (404). I guess it's because of the staticfilehandler ends the request, but is there any good solution for this problem ? I have tried the same s...

How to modify HEAD element by using HttpModule

I want to add html meta data dynamically to the HEAD element of an aspx-page by using a HttpModule. When I hook to the PreRequestHandlerExecute event the Header property of the page is null. When I hook to the PostRequestHandlerExecute event the Header property is available but adding controls to it doesn't seem to work. When debugging...