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?
IMO - HTTPContext.Items
is the best way to do this.
Ref.: https://web.archive.org/web/20201202215202/https://www.4guysfromrolla.com/articles/060904-1.aspx
HTH.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With