Feed on
Subscription

Contact ASP.Net(15 intimately)

The condition in ASP.Net is saved

Save in ASP a few share, individual condition,Those who use is Application, Session, Cookie these three kinds.Breathe out ah.Besides successive Application substandard in the M$ in ASP.Net,Give variable of our new a kind of condition information State again,It is to be used save WEB to accuse the variable of condition,Very fresh,Must know quickly:)

Feel embarrassed,Flying knife or from primitive one step by step for.Tell from Application first case.(A roaring) ,Without method,To have a sex of a flight of stairs,Still ought not to contact prematurely new east east:)

Application

In ASP.Net Application usage and ASP are same,It is almost without what what says,But it became much two particularly useful incident,Application_OnBeginRequest and Application_OnEndRequest.Their mixing is like original Application_OnStart and Application_OnEnd those who be put in Global file (notice this file is in ASP the name is Global.asa,Global.asax) is in ASP.Net.

Note:This incident,Write writing On is same.If Application_End and Application_OnEnd are same

Application_OnStart is the incident that is sparked above all in whole ASP.Net application,Spark when program of the first ASP.Net in a fictitious catalog is carried out namely,Application_OnEnd solicit comments is very contrary,Be sparked when whole application stops (happen in the server to be restarted normally / close when machine) .Application_OnRequestStart and Application_OnRequestEnd are happen when each ASP.Net program is requested,That is to say the client visits an ASP.Net program,These two incident can be sparked.We can see his application from the program below. We build a Global.asax first, content is as follows:

%26lt;script Language= %26quot;C#%26quot; Runat= %26quot;server%26quot; %26gt;

Void Application_OnBeginRequest(Object Sender, eventArgs E)
{
Response.Write("Request Is Starting. . . %26lt;br%26gt;%26quot; );
}

Void Application_OnEndRequest(Object Sender, eventArgs E)
{
Response.Write("Request Is Ending. . . %26lt;br%26gt;%26quot; );
}

%26lt;/script%26gt;

Below the root list that puts its this fictitious list next, next we open what Aspx file casually,We open Named.aspx file here,Look:



Graph 19-1

See without,Of this page above and below appeared the statement Request Is Starting that we define in Global.asax. . . With Request Is Ending. . . This is not us in what add alone in this file,The sign that we will see it in any ASP.Net file again.

Session

The Session in ASP.Net is I had seen best processing,It is other trends webpage technology cannot be likened to.The support that the Session in ASP.Net also does not need Cookies again,That is to say if the user shut Cookie,Also can be saved like the value of Session.

Nevertheless,We need to undertake to Config.web file a few make up,Because amid is found about the setting text of Session,Be like:

%26lt;sessionstate
Cookieless= "false "
/ %26gt;

Change Cookieless= "false" into Cookieless= "true" ,So later Session does not store was in in Cookies,And storing in URL.



Graph 15-2

In the black group above east east the Session that stores namely is worth,Of course this is be coded,The straight fact that we cannot know it is worth.

Actually,I discover,Need not alter Config.web document,After putting out Cookies,Need not URL also can deliver Session to be worth all the same,The Session below this kind of circumstance is how keep a cost,This not quite clear:)

The art that Session still can carry not dead,Restart when the server namely,The cost that still can make sure Session is medium is fixed,Nevertheless this should alter again Config.web file.Also be to adopt the statement set below.

%26lt;sessionstate
Inproc= "false "
Server= "localhost "
Port= "42424 "
/ %26gt;
The Session that discovers here is very powerful ah:) ,the lead plane that Localhost changes to want into you,Session still can be on a lead plane maintain.


 
Related:

    Submit: