1

So I have the following code contained within an HttpModule in an application I've been asked to support:

app.Context.Response.ContentType = "text/xml";
app.Context.Items.Add("IpixRoomId", ipixRoomId);
app.Context.Items.Add("IpixId", ipixId);
app.Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
app.Context.RewritePath(rewriteUrl, true);

What's the purpose of adding data to Context.Items when the content type is XML?

EDIT: For clarification, I'm calling up this URL:

http://website.com/virtualtour/1971/6284/panorama2flash.swf

I assume the SWF file (I know very little about Flash) makes another call to http://website.com/virtualtour/config.xml. The code I pasted above only executes on calls to config.xml. So since it's only the SWF file and config.xml being requested from the server, I'm a little confused. Can the .SWF file have access to HttpContext.Current.Items?

Other than the HttpModule, there is no .NET involved in the code, it's a straight request to the SWF file which triggers a call to config.xml but it seems that those Context.Items contain the data needed to make the SWF file display the right virtual tour. I'm just missing where that link happens. It can't happen in the XML, so maybe in Flash?

1
  • I would ask the original author the intent of the calls if it cannot be derived by looking at the code. It is possible that there were other modules in the request pipeline (or methods in the same module) that would've made use of the information stored in the HttpContext.Items. Jan 12, 2011 at 21:51

1 Answer 1

1

HttpContext.Items is a temporary repository that lives for the span of the request, it is generally used in modules to share state within/with other modules and with the pipeline that is handling the request.

The main reason is exactly that, passing information back and forth.

4
  • I know what Context.Items is for, the question is what application would it have when the content type is XML?
    – Scott
    Jan 12, 2011 at 21:39
  • @Scott Schluer well the reason to use it still maintains regardless of the request's content type. It is simply for sharing state information across the scope of the current request. Jan 12, 2011 at 21:40
  • Well what do you know...there was an HttpHandler buried and cryptically named that actually makes use of those.
    – Scott
    Jan 12, 2011 at 21:55
  • @Scott Schluer they are the most fun when they seem to have no relation to the executing code lol, been there. Jan 12, 2011 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.