C# - Detect If Content Has Been Compressed In My HttpModule?

Mar 25, 2011

I have an HttpModule which is used to dynamically compress content from an ASP.NET (MVC3) web application. The approach is very similar to the CompressionModule in this article (where the module applies a GZip filter to the HttpResponse and sets the correct Content-encoding header).For one reason and another, this needs to run in classic mode, not integrated pipeline mode.

The problem I've got, is that on some servers that have IIS compression enabled, IIS compresses the content and then my module compresses that. The upshot is that I get content compressed twice, with an encoding:

Content-encoding: gzip,gzip
one from IIS, and one from this line in my code:

httpResponse.AppendHeader("Content-encoding", "gzip");

Does anyone know a way, in classic mode, that I can check to see if the content is already compressed, or if compression is enabled on the server, in order to bypass my own compression?In pipeline mode, this check is as simple as

if (httpResponse.Headers["Content-encoding"]!= null)
{
return;
}

i.e. check if anything has already set a content-encoding and if so, do nothing.However, I'm stumped in classic mode. Unfortunately, accessing HttpResponse.Headers is not allowed in classic mode, so I can't do my barrier check.

View 1 Replies


Similar Messages:

HttpModule : Detect First Request In A Session?

Sep 2, 2010

I have written a HttpModule for our site which generally accepts requests and checks for specific file extensions as well as the value of a specific session variable. Is it possible to detect the first request in a session?

View 1 Replies

.NET/IIS6 - Disable Chunked Encoding When Using Dynamically Compressed Content?

Oct 7, 2010

I'm running ASP.NET on an IIS6 server. Right now the server is set up to compress dynamically generated content, mainly to reduce the page size of ASPX files that are being retrieved.

Once of the ASPX files has the following bit of code, used to fetch a file from the database and send it to the user:

Response.Clear();
Response.Buffer = true;
Response.ContentType = Document.MimeType;[code]....

The download itself works perfectly. However, the person downloading the file doesn't get a progress bar, which is incredibly annoying.

From what research I've been doing, it seems that when IIS sets the transfer-encoding to chunked when compressing dynamic content, which removes the content-length header as it violates the HTTP1.1 standard when doing that.

What's the best way to get around this without turning dynamic compression off at the server level? Is there a way through ASP.NET to programatically turn off compression for this response? Is there a better way to go about doing things?

View 1 Replies

AJAX :: HTMLEditor - Detect Change In Content?

Jun 21, 2010

I have successfully implemented a page using a custom verison of the HTML Editor. Now I would like to check to see if the user has modified the content in the editor window and prompt them prior to leaving the page.

I am trying to do this in client side java script (but would be happy to do it server side) and can not seem to detect if there is even content in the HTMLEditor control, so there is no way I will get to the point of seeing if it changed.

View 2 Replies

ASP.NET: What Does HttpModule Do - System.ServiceModel.Activation.HttpModule

May 31, 2010

the purpose of this HttpModule? It's showing up on my HttpModuleCollection list, but I don't know what's it's for.System.ServiceModel.Activation.HttpModule

View 3 Replies

Detect Automated Agents That Are Coping The Content Of Site?

Mar 21, 2011

I notice that some sites are coping the content of one of my client's sites using automated agents. I want to detect their requests and show them a captcha code to prevent them from coping the site content. Is there anyway to detect them?

View 2 Replies

Web Forms :: Create Compressed RAR Zip Files?

Sep 20, 2015

is there any library to rar&unrar files in C#?

if there isn't, any compression libraries for c#?

View 1 Replies

Iis - How To Support Compressed HTTP Requests In IIS7

Dec 10, 2010

For an ASP.NET 4.0 / IIS7 web app, I would like to support compressed HTTP requests. Basically, I would like to support clients that would add Content-Encoding: gzip in the request headers, and compress the body accordingly.

Does anyone known how I achieve such a behavior?

View 1 Replies

MVC - Enabling Caching Of The Compressed Page Output?

Sep 30, 2010

I've seen a number of options for adding GZIP/DEFLATE compression to ASP.Net MVC output, but they all seem to apply the compression on-the-fly.. thus do not take advange of caching the compressed content.

Any solutions for enabling caching of the compressed page output? Preferably in the code, so that the MVC code can check if the page has changed, and ship out the precompressed cached content if not.

This question really could apply to regular asp.net as well.

View 3 Replies

AJAX :: Use Control Toolkit To Dowloaded The Compressed Folder?

Dec 13, 2010

I'm making a asp.net web project using visual web developer 2010. I want to use ajax control toolkit so I have dowloaded the compressed folder and I added a tab in my project with all the ajax control toolkit. The problem is when I try to run the project it gives me the following message: " It's impossible to find the file 'd:hgactServerAjaxControlToolkitExtenderBaseExtenderControlBase.cs'.

After an Internet researcj , I supposed that this error is caused by the fact that I created a simple web project, while I had to create a ajax web toolkit project. The question is:how can I create it?? In the home page of visual web developer 2010 the model "ajax control toolkit web site" doesn't appair in the installed models!! How can I import it, or can I solve this problem in general?

Is it true that it has been originated that the fact I created a simple web project instead of a ajax control toolkit project?

View 3 Replies

Httphandler And Httpmodule In .net?

Jan 7, 2011

As i know that asp.net fulfill all the requirements for any web application but what are the ground rules for creating custom httphandler and httpmodule in asp.net.Edit:For example I want to fetch image from database then what i should i use httphandler or normally read image from database.If httphandler then why?

View 4 Replies

C# - HttpModule Does Not Intercept Js And Css Files In IIS 5.1.

Feb 14, 2011

I am implementing HttpModule for compressing request.Below is the codee for HttpModule:

public class Global : IHttpModule
{
public void Init(HttpApplication app)
{[code]....

It's able to intercept and compress js and css in the development web server but when i run it from IIS 5.1 it is not able to compress js and css files.

View 2 Replies

.net Httpmodule Execution Order?

Sep 14, 2010

Does the order of httpmodule execution match their order in the web.config or is it undefinied?

View 1 Replies

HttpModule Over Multiple Sites

Nov 2, 2010

I have custom redirection implemented in a module. Do I have to modify each config for all sites or is there a more general approach?Also, I have files in App_Data for this module, which would cause replication.

View 1 Replies

C# - Hook Into Application_Start In A HttpModule?

May 6, 2010

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?

View 3 Replies

Is It Safe To Use An HttpModule For Localization

Feb 10, 2011

I'm considering making use of an HttpModule for localization purposes (based on the example in this article) - but I'm curious, is this safe?

Here's the code, for reference:

public class CookieLocalizationModule : IHttpModule
{
public void Dispose()
{
}

[code]....

I was under the impression that multiple threads could potentially service a web request. Is it safe to set the Current/Current UI Cultures in an HttpModule like this and have it respected for the life of the web request regardless of how many threads are involved in servicing it?

View 1 Replies

HTTPModule Only Getting Called Once Per Page?

Aug 15, 2010

I am trying to implement a custom HTTPModule for ASP.NET. I have a very simple html page with an image in it and an HTTPModule that hooks into the BeginRequest event. When I debug with Visual Studio's dev web server, my module is called twice: one for the initial page request, then once for the image request. This is what I expected. However, when I deploy my application to IIS, the module is only being called once for the page request.

View 2 Replies

C# - Access Js And Cs File In HttpModule?

Feb 14, 2011

How to access Js and css file in HttpModule?

View 1 Replies

Track Each Request To The Website Using HttpModule

May 14, 2010

I want to save each request to the website. In general I want to include the following information: User IP, The web site url, user-if-exist, date-time. Response time, response success-failed status. Is it reasonable to collect the 1 and 2 in the same action? (like same HttpModule)? Do you know about any existing structure that I can follow that track every request/response-status to the website? The data need to be logged to sql server.

View 3 Replies

HttpHandlers / Modules :: HttpModule Is Not Working

Jan 24, 2010

I have written simple http module just to print Hello. but it is not working.

View 10 Replies

Asp.net - Is HttpModule Shared Among Working Threads

Apr 11, 2010

Do I have to lock access to instance members?

public class HttpModule : IHttpModule
{
//...
Dictionary<int, int> foo;
void UseFoo(int a, int b)
{
foo[a] = b;
}
}

View 2 Replies

Adding A Footer To The Page In HttpModule

Dec 30, 2010

I could use late events such as EndRequest and put inside Response.Write but this way whatever I'm adding would come after the /html tag and the HTML won't be well formed.

View 1 Replies

Security :: Blocking IP Address Using HTTPModule?

Nov 19, 2010

I want to increase the security of my website, does creating http module that block certain ip address will increase security?

Since IP Address can be manipulated if I'm not mistaken, I'm not sure that creating HTTP Module will help.

View 1 Replies

C# - Selecting HttpHandler From Custom HttpModule?

Feb 17, 2011

I have an HttpModule and I'd like to choose the HttpHandler for the current request, is that possible? Also web.config is not an option because the condition is not based on path or extension. My googling skills have failed me, no matter what keywords I use all the results are "IHttpHandler vs IHttpModule".

View 3 Replies

C# - Limit HttpModule With ONLY ONE Call Per Request?

Apr 1, 2011

Here is my implementation of HttpModule:file with module:

public class HttpModuleRewriter : IHttpModule
{
#region IHttpModule
[code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved