. NET knowledge sorting notes,. net sorting notes
This article is written on your own. If you have any mistakes or do not want them to be fully supplemented !~
1. node operations in the Web. Config configuration file.
In the Web. write in Config. <configuration> <connectionStrings> <add name = "conStr" connectionString = "Data Source = IUCL8V4Y7NW5IRA \ SQLEXPRESS; Initial catalog = BookShopPlus; User Id = sa; pwd = sa123 "/> </connectionStrings> </configuration> when accessing the DAL layer (written in SqlHelper): private static string conStr = ConfigurationManager. connectionStrings ["conStr"]. toString ();
2. Determine whether to send back and load for the first time.
Page. IsPostBack = TRUE indicates sending back, and Page. IsPostBack = FALSE indicates loading for the first time.
3. Difference between Post and Get in Form labels
① Get is to get data from the server, and post is to send data to the server. ② get is to add the parameter data queue to the URL referred to by the action attribute of the submission form. The values correspond to each field in the form one by one and can be seen in the URL. post uses the HTTP post mechanism to place fields in the form and their content in the html header and send them to the URL address indicated by the action attribute. the user cannot see this process. ③ for the get method, the server uses Request. queryString [] obtains the value of a variable. for the post method, the server uses Request. form [] to obtain submitted data. ④ The data volume transmitted by get is small and cannot exceed 2 kb. the amount of data transmitted by post is large, which is generally not restricted by default. theoretically, the maximum size of IIS4 is 80 KB, and that of IIS5 is 100KB.
4. When <form action = "LoginHandler. ashx" method = "post">
String s = context. Request. Form ["Name"]. ToString () ;=> get the Name value in the URL
5. When <form action = "LoginHandler. ashx" method = "get">
string s = context.Request.QueryString["txtLoginId"].ToString();
6. context. Request ["txtLoginId"]. ToString (); both post and get can be used.
7. common attributes and methods of the Request object:
① QueryString: Get the data transmitted through the URL path. string s = context. request. queryString ["txtLoginId"]. toString (); ② Form: Get the data submitted and transmitted through the Form. string s = context. request. form ["Name"]. toString (); ③ ServerVariables: a set of Web server variables. string Agent = context. request. serverVariables ["HTTP_user_AGENT"]. toString (); ④ Params: a set of the above three methods. ⑤ MapPath () method: maps the specified virtual path to the physical path. string path = context. request. mapPath ("/upload/Users.txt ");
8. common attributes and methods of ReSponse objects
① ContentType: gets or sets the http mime type of the output stream. The default value is "text/html ". context. response. contentType = "text/plain"; ② Write () method: Output content directly on the page. response. write ("Hello Word"); ③ Redirect () method: redirects to another page. response. redirect ("Index. aspx "); ④ End () method: Enable the Web server to stop the program of the day and return results. response. end ();
9. Page Object: Page control class.
① IsPostBack: whether it is loaded for the first time. ② Request: the Request on the current page. ③ Controls: a set of server Controls. ④ DataBind () method: bind the data source to the called Server Control. ⑤ Load event: This event occurs when the server control is loaded to the Page object.
10. cookie is a good way to store customer data. Unlike sessions that can also be used to store customer data, session stores data on the server,
Cookie stores data on the client. The most common cookie application we use is storing Forum information.
Usually, there are choices like "whether to save your login information". If you select this option, next time you log on to this forum
You can log on directly without entering the login form.