views:

22

answers:

1

I am writing an ASP.NET application that initializes some contextual data based on stuff sent through the Request object. How should I be storing this so that it is only visible to objects dealing with the request?

Essentially I have an HttpModule that looks at the request, and does something based on the incoming data:

public void OnBeginRequest(object sender, EventArgs e){
    if((sender as HttpApplication).Request.Url.Host == "something"){
        // Store some extra information here
    }
}

And then I want to retrieve the data later on in the pipeline, in a view

<%: somehowGetRequestSpecificData.MyProperty %>

How and where should I be storing that stuff?

A: 

IMO - HTTPContext.Items is the best way to do this.

Ref.: http://www.4guysfromrolla.com/articles/060904-1.aspx

HTH.

Sunny
Thanks. Are there any other options?
Krisc