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 6142897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:26:59+00:00 2026-05-23T18:26:59+00:00

I create an IIS Module that appends text to the page before it loads.

  • 0

I create an IIS Module that appends text to the page before it loads. When I go to the URL, this works perfect the first time the page loads. On subsequent loads, however, the text is never appended.

Any thoughts on how to remedy this?

== CODE ==

Here’s my web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <compilation debug="true" />
    </system.web>
    <system.webServer>
        <modules>
            <add name="MIModule" type="MI.MyModule, MI" />
        </modules>
        <caching enabled="false" enableKernelCache="false" />       
    </system.webServer>
</configuration>

Some module code:

public void context_PreRequestHandlerExecute(Object source, EventArgs e)
        {
            HttpApplication app = (HttpApplication)source;
            HttpRequest request = app.Context.Request;

            string pageContent = app.Response.Output.ToString();

            string useragent = "HI!<br />" + pageContent + "<hr />" ;

            try
            {
                _current.Response.Output.Write(useragent);
            }
            catch
            {
            }
        }

and the rest of the code:

private HttpContext _current = null;

        #region IHttpModule Members

        public void Dispose()
        {
            throw new Exception("Not implemented");
        }

        public void Init(HttpApplication context)
        {
            _current = context.Context;

            context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
        }

        #endregion
  • 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-23T18:27:00+00:00Added an answer on May 23, 2026 at 6:27 pm

    Is the _current variable actually HttpContext.Current? Is it a static field in your module? When/how is it initialized? My guess is that the empty catch clause gobbles up all errors, and following that thought, you most probably get a null reference on _current. Try removing the try/catch to learn more on what’s wrong with your code

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

Sidebar

Related Questions

I have installer that will create virtual directory. It works fine on IIS 6.
I have created a basic WCF service in IIS. I am aware that this
I've created a custom module for IIS that I want to run some tests
I have an innosetup installer that needs to create an IIS Virtual Directory. In
How do I create an Application Pool on IIS 6.0 using a PowerShell script?
I need to create a photo gallery for a website running IIS 4.0 or
I've create a web site on my local IIS 7 with my own ASP.Net
Is it possible to create a virtual folder in IIS from an ASP.NET site?
What install tool can I use to create Virtual Directory on IIS? OpenSource, free
help me to manage IIS (what i am trying to do is create virtual

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.