Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If it's just for passing values between pages and you only require it for the one request. Use <code>Context.</code></p> <blockquote> <p><strong>Context</strong> </p> <p>The Context object holds data for a single user, for a single request, and it is only persisted for the duration of the request. The Context container can hold large amounts of data, but typically it is used to hold small pieces of data because it is often implemented for every request through a handler in the global.asax. The Context container (accessible from the Page object or using System.Web.HttpContext.Current) is provided to hold values that need to be passed between different HttpModules and HttpHandlers. It can also be used to hold information that is relevant for an entire request. For example, the IBuySpy portal stuffs some configuration information into this container during the Application_BeginRequest event handler in the global.asax. Note that this only applies during the current request; if you need something that will still be around for the next request, consider using ViewState. Setting and getting data from the Context collection uses syntax identical to what you have already seen with other collection objects, like the Application, Session, and Cache. Two simple examples are shown here: </p> </blockquote> <pre><code>// Add item to Context Context.Items["myKey"] = myValue; // Read an item from the Context Response.Write(Context["myKey"]); </code></pre> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc300437.aspx#S6" rel="nofollow">http://msdn.microsoft.com/en-us/magazine/cc300437.aspx#S6</a></p> <p>Using the above. If you then do a <code>Server.Transfer</code> the data you've saved in the context will now be available to the next page. You don't have to concern yourself with removing/tidying up this data as it is only scoped to the current request.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload