1. Page jump:
(1 server transmission
Server. Transer (http://www.jb51.net); after directed to the new page, the original URL will still be displayed, the browser will not return to the original page, the history will not be recorded.
Applies to complete control transmission, such as the installation wizard.
(2 hyperlink
(3. the browser redirects Redirect, which is fast and has not been sent to the server.
(4 send PostBackUrl = "http://www.jb51.net"/>
IsCrossPagePostBack is used to determine whether cross-page submission is performed.
IsPostBack is used to check whether the current webpage is loaded for the first time. When the user browses this webpage for the first time, Page. IsPostBack returns False, and returns True after loading.
2. debugging
(1. modify. add Trace = "true" to the Page command at the top of the aspx Page to operate and view it in the browser (corresponding to the status code). After testing, remember to change "true" to "false !!!!
(2 insert Trace. warn ("111") Trace. warn ("cATEGORY", "11", excp );
Copy codeThe Code is as follows:
Try {int a = 0; int B = 5/;}
Catch (System. Exception ex) {Trace. Warn ("zzl", "calling B = 5/a", ex );}
The browser will display in Red:
(3. web. config application trace
(4. breakpoint debugging
3. form: get and post
Get uses the url to pass the value, and post hides the form value from the http message and does not display it.
Get data is limited, so post can transmit large data volumes.
However, the browser prompts you to resubmit the form in post, but the get does not.
4. Disable viewstate: unable to read the value last sent to the client
Auto-increment: addTest. ashx
Copy codeThe Code is as follows:
Public void ProcessRequest (HttpContext context ){
Context. Response. ContentType = "text/plain ";
String ispostback = context. Request ["ispostBack"];
String value = "0 ";
If (ispostback = "true "){
Value = context. Request ["num_01"];
Int valueInint = int. Parse (value );
ValueInint ++;
Value = valueInint. ToString ();
}
String filepath = context. Server. MapPath ("addTest.htm ");
String content = System. IO. File. ReadAllText (filepath );
Content = content. Replace ("@ value", value );
Context. Response. Write (content );
}
Html
Copy codeThe Code is as follows:
<Form action = "addTest. ashx" method = "post">
<Input type = "hidden" name = "ispostBack" value = "true"/>
<Input type = "hidden" name = "num_01" value = "@ value"/>
<Div> @ value
</Div>
<Input type = "submit" name = "" value = "addOne"/>
</Form>
5. cookie
In addition to common html data and cookies, the server returns the cookie value to the local browser, which may consume too many resources.
Http://www.jb51.net so the website's image server will be different from the main site domain name, reduce cookie Traffic Transmission to optimize the site rate: http://www.myblogs.com/daomul.gif
6. Each request will process an instance with the new IhttpHandler Interface Class "variable 1 ".
GC is used up, and the previous value is not maintained.
Use static "save" to access all the instances
Copy codeThe Code is as follows:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Public partial class vivideo_test _ variable 1: System. Web. UI. Page
{
Private int I = 0;
Private static int j = 0;
Protected void Page_Load (object sender, EventArgs e)
{
}
Protected void button#click (object sender, EventArgs e)
{
// I ++;
// Label1.Text = I. ToString ();
J ++;
Label1.Text = j. ToString ();
}
}