Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 20th, 2007, 12:09 AM
SV SV is offline
Authorized User
 
Join Date: Oct 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to use PreSendRequestContent

I have bben trying to alter the output of a page using PreSendRequestContent. The event get raised but the contents of the document do not change. Here is an example from ASP.NET Professional 2.0 Special Edition.

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace Demo
{
    public class AppendMessage : IHttpModule
    {
        private HttpContext _current = null;

        #region IHttpModule Members

        public void Dispose()
        {
            throw new Exception("The method or operation is not implemented.");
        }

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

            context.PreSendRequestContent +=
                new EventHandler(context_PreSendRequestContent);
        }

        void context_PreSendRequestContent(object sender, EventArgs e)
        {
            //alter the outgoing content by adding a HTML comment.
            string message = "<!-- This page has been post processed at " +
                             System.DateTime.Now.ToString() +
                             " by a custom HttpModule.-->";

            _current.Response.Output.Write(message);
        }
        #endregion
    }
}

I looked on the internet and find examples which have similiar code. Can anyone suggest why does not get appended to the contents of the document.

Thanks.
 
Old December 6th, 2007, 02:50 PM
Registered User
 
Join Date: Dec 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

why do you have comment tags "<!-- This

 
Old December 6th, 2007, 05:25 PM
SV SV is offline
Authorized User
 
Join Date: Oct 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

.. because I get want to put a comment in the page.









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.