HttpContext.Current.Items and HttpModule RRS feed

  • Question

  • User-1856393782 posted
    I've written an HttpModule that adds an item to the HttpContext Items collection before rewriting the path. I modeled my HttpModule on the one that is used in the Community Starter Kit / GotCommunity. SiteModule.cs public void Init(HttpApplication application) { application.BeginRequest += (new EventHandler(this.Application_BeginRequest)); } private void Application_BeginRequest(Object source, EventArgs e) { // Get abbreviated reference to current context HttpContext Context = HttpContext.Current; string requestPath = SiteGlobals.RemovePathInfo( Context.Request.Path.ToLower() ); // Figure out the page and add to Context string pageName = SiteGlobals.GetPageName(requestPath); Context.Items[ "myPageName" ] = requestPath; Context.RewritePath(SiteGlobals.UrlBasePage); } The HttpModule runs fine and sends the request on to the correct page (SiteGlobals.UrlBasePage). At the default page for the site I then try and access Context.Items, but have had no luck thus far. siteDefault.cs void Page_Init(Object s, EventArgs e) { string pageName = (string)HttpContext.Current.Items[ "myPageName" ]; lblTest.Text = "Context.Items[ \"myPageName\" ] = " + pageName; } Context.Items[ "myPageName" ] returns nothing. Any idea why I'm not finding the value stored in the HttpContext.Items collection?
    Sunday, February 1, 2004 1:35 AM

All replies

  • User-1856393782 posted
    Sorry, folks ... false alarm. After a day away from the code I took a look again last night and realized that I wasn't working with the most current code. The assembly that was being built from the project wasn't being placed in the /bin folder. I copied the new assembly in and everything works fine. Problem solved.
    Tuesday, February 3, 2004 11:41 AM