Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7086369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:32:28+00:00 2026-05-28T07:32:28+00:00

I have created a simple HttpModule which removes whitespaces from response before sending it

  • 0

I have created a simple HttpModule which removes whitespaces from response before sending it to the client. This works fine for an aspx page on IIS7.0 but if i create a static html page and call it, the HttpModule does not kick in (the way i know is because the source contains whitespaces, which otherwise should have been removed). Apparently there is something i m not doing right, but dont know what.

My website is in an Application Pool with .NET 4.0 and ManagedPipelineMode = Integrated.

I have added my module as a ManagedModule and refers to an strong-name-key assembly from GAC.

thanks

Edit- here is the system.webserver part from web.config

<system.webServer>
  ...
  <modules runAllManagedModulesForAllRequests="true">
    <add name="RemoveWhitespaceHttpModule" 
         type="HttpModules.Modules.RemoveWhitespaceHttpModule, HttpModules, 
           Version=1.0.0.0, Culture=neutral, PublicKeyToken=8a83u4bi47o9fo0d" 
           preCondition="" />
  </modules>
  <defaultDocument>
    <files>
      <add value="TestForm.aspx" />
    </files>
  </defaultDocument>
</system.webServer>

Edit- Fixed it. For anyone interested, this is how my module checks the response and then decides whether to proceed with whitespace removal or not

if (contentType.Equals("text/html") 
  && httpContext.Response.StatusCode == 200 
  && httpContext.CurrentHandler != null)
{ ... }

The problem was with the third condition above httpContext.CurrentHandler != null. when calling this module for static .html pages, the currentHandler was null and hence the code never went inside to manipulate html. i have removed this third condition and it works now. thanks for your answers everyone

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:32:29+00:00Added an answer on May 28, 2026 at 7:32 am

    This should do the trick, in the web.config:

    <modules runAllManagedModulesForAllRequests="true"></modules>
    

    This is a quick and easy solution, but can cause issues / performance issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone help me on this, I have created simple web services using axis2
I have created a simple wcf service which used the WCF Service Library template.
I have created a simple Asp.Net custom control which automatically combines all the correct
i have created a simple public ref class in the vc++ project, which is
Have created simple Ajax enabled contact forms before that have around 12 fields -
I have created simple Java class to test file writes from applets: update appeared
I have created a simple chat server that is driven by client polling. Clients
I have created simple .aspx page which queries a database for some live data
I have created a simple class to filter out data from a data stream.
I have created a simple login page which is based on the sessions. session_start();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.