ASP. NET learning note _ 03 page Jump, debugging, Form, viewstate, cookie

Source: Internet
Author: User

1. Page jump:

(1 server transmission

Server. transer (http://www.cnblogs.com/daomul/); 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.cnblogs.com/daomul/"/>

IscrosspagePostBack is used to determine whether a 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 the page command at the top of the. ASPX page, add trace = "true", and operate and view it in the browser.Code). After testing, remember to change true to false !!!!

(2 insert trace. Warn ("111") trace. Warn ("category", "11", excp );

1 Try{IntA =0;IntB =5/A ;}2 Catch(System. Exception ex) {trace. Warn ("Zzl","Calling B = 5/", Ex );}

The browser will display in Red:

(3 Web. config ApplicationProgramTrace

(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

 1   Public   Void  Processrequest (httpcontext context ){  2 Context. response. contenttype = "  Text/plain  "  ;  3           String Ispostback = context. request [ "  Ispostback  "  ];  4           String Value = "  0  "  ;  5           If (Ispostback = "  True  "  ){ 6 Value = context. request [ "  Num_01  "  ];  7                Int Valueinint = Int  . Parse (value );  8 Valueinint ++ ;  9 Value = Valueinint. tostring ();  10   } 11   12           String Filepath = context. server. mappath ( "  Addtest.htm  "  );  13           String Content = System. Io. file. readalltext (filepath );  14 Content = content. Replace ( "  @ Value  "  , Value ); 15   Context. response. Write (content );  16 }

Html

 <  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.cnblogs.com/daomul/ 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

 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 ();}} 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.