locked
Add page header(change CSS) with IHttpModule RRS feed

  • Question

  • User1999148159 posted

    hi

    i have a problem, i use a IHttpModule  to process some request in my asp.net website.

    thus i need to change css of page dynamically and i do this with some code in page shown is below:

    HtmlHead Head = this.Page.Header;

    Head.InnerHtml = "<link href=\"ss2.css\" rel=\"stylesheet\" type=\"text/css\" />";

    now i want to change css from iHttpModule.BeginRequest and i cant find any way to access Page object.

    can you please help me?

    best regards

    Ali Mohammadi

    Monday, May 21, 2007 2:24 AM

Answers

  • User-900677162 posted

    Hi, Ali Mohammadi

    I believe you can not access the page object in a HttpModule: 

    After the HttpApplication object massages the request, it pushes the request through one or more HttpModule objects. There are a number of system-level HTTP modules, providing services ranging from authentication to state management to output caching. The number of modules that get to intercept the request is based upon settings within the host machine's machine.config file and the application's web.config file. In classic ASP, this role of providing pre- and post-processing fell upon ISAPI filters. It turns out that ASP HTTP modules are more straightforward to write.

    The final piece of the chain is the HttpHandler. If you've been working with ASP.NET for a while, you're familiar with the System.Web.UI.Page class. The Page class is an HttpHandler object, implementing the interface IHttpHandler. Classes implementing IHttpHandler can hook into the HTTP pipeline and service requests through the interface's ProcessRequest method.

    So HTTPModules can take the request and do anything to it before a Page object is created and used.

    More details: 

    http://msdn.microsoft.com/msdnmag/issues/02/05/asp/

    I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 23, 2007 9:57 PM

All replies

  • User-900677162 posted

    HI,

    I recommend you to use HttpHandler to dynamically change the CSS variable.

    http://www.codeproject.com/useritems/CSSVariables.asp

    I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance

    Tuesday, May 22, 2007 11:33 PM
  • User1999148159 posted

    Hi Rex
    thanks for your heeds :-)
    that article is great and help me but it seems as though describ how change CSS value dynamically, my CSS is a big file and i think changing all values is too long, rather than i create two CSS and want to change it dynamically, so i need access to sender page object in HTTPModule.

     Best Regards

    Ali Mohammadi

    Wednesday, May 23, 2007 6:42 AM
  • User-900677162 posted

    Hi, Ali Mohammadi

    I believe you can not access the page object in a HttpModule: 

    After the HttpApplication object massages the request, it pushes the request through one or more HttpModule objects. There are a number of system-level HTTP modules, providing services ranging from authentication to state management to output caching. The number of modules that get to intercept the request is based upon settings within the host machine's machine.config file and the application's web.config file. In classic ASP, this role of providing pre- and post-processing fell upon ISAPI filters. It turns out that ASP HTTP modules are more straightforward to write.

    The final piece of the chain is the HttpHandler. If you've been working with ASP.NET for a while, you're familiar with the System.Web.UI.Page class. The Page class is an HttpHandler object, implementing the interface IHttpHandler. Classes implementing IHttpHandler can hook into the HTTP pipeline and service requests through the interface's ProcessRequest method.

    So HTTPModules can take the request and do anything to it before a Page object is created and used.

    More details: 

    http://msdn.microsoft.com/msdnmag/issues/02/05/asp/

    I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 23, 2007 9:57 PM