Asp. NET Basics (i)

Source: Internet
Author: User
Through a few days of interview to find a law, for the university students who have not graduated, have how many project experience is not the most important, the enterprise is more to the basic knowledge of the mastery of the level of high-rise, now I summarize this basic knowledge, also as learning notes!

The difference between website and WebApplication
1) When changing the background code, WebApplication need to restart the browser or rebuild the solution, while the website is not;
2) Website no solution, no namespace, not conducive to the development of engineering.

What is the way HTTP works?
1) The client submits the form request processing requests
2) server-side handlers are processed Handle
3) service side corresponding Response
Note: The form elements that are submitted to the server must add the Name property because the server only recognizes name, which is different from jquery and Dom, and they only recognize the ID.

The method property of the form specifies how the form is to be submitted *
1) Get (the default value) is to pass the form explicitly through the URL of the address bar;
The form values that are passed by post are hidden in the HTTP message and are not visible in the URL address bar;
2) The number of get pass-through values is limited and is affected by the length of the address bar, as if the maximum is 2K bytes, while post is not limited.
3) post when the page is refreshed, there will be a browser prompt to resubmit the form's dialog box, and get is not.

The content in the Div is not submitted to the server?
Only value values (such as input, textarea, select, and so on) that have the name attribute set to the div are submitted to the server

ViewState principle
1) Hide some fields to hold controls that do not have value property values
2) Because HTTP is a stateless protocol, when the page changes, it will use ViewState to maintain the state of the page.
3) For example: The Label control is rendered as a <span> tag by the browser, so the value of the label exists in ViewState;
Similarly, the TextBox control is rendered as the input tag by the browser, and the value in the TextBox is not saved because the textbox is essentially input,input itself to the server and does not need to hide the field.
4) The Viewstatedecoder tool can be used to view the true content of viewstate.

Advantages and disadvantages of state information saved in hidden fields (ViewState)
1) Increase website traffic
2) Reduced access speed
3) confidential data placed on the form will have security issues such as data spoofing (such as online banking, etc.). *

All the backstage programs are implemented by the IHttpHandler interface

Cookies and sessions are used to store relevant data for the current client,
The cookie is stored on the client side and the session is stored on the server.
Note: It is not possible to save too much data in the session, it is the object type of data, so it is necessary to use the type to replace.

HTTP request message, each type of element on the page, such as IMG, JS, CSS and other files are requested separately. This can be viewed through the developer tools or the famous Firebug.
* HTTP is a "stateless" protocol, so it will not remember the last time to do anything, do not remember to send the browser * * information, so when the next time it re-request, IMG, JS, CSS and other files will be sent back to the header information.

Get is passed explicitly by a parameter passed through the URL address bar, such as:? A=123&B=ABC

Post is not passed through the URL, but it silently transmits the data in the background, with the __viewstate to transmit implicitly.

HTTP various status code meanings
1) 200 Series, indicates the request is successful, OK
2) 300 series, such as 307, indicates server redirection, need to do further processing;
3) 400 series, such as 404, indicates that the page was not found, file not found.
4) 500 series, which indicates an internal server error.

Background Write Delete button The commit event is to add the OnClientClick property in the button control to the
<input type= "Submit" name= "delete" value= "delete" onclientclick= "return confirm (' OK to delete? ') "/>
You can prompt the client in a friendly manner to avoid unnecessary deletions.

127.0.0.0 is a loopback address, which means access to this machine, not through the network card, cannot be accessed in the field, alias is localhost.
0.0.0.0 represents any Ip,anyip.

Convert HTML, JS to normal pair
Httputility.htmlencoder (string s)//convert to special characters, for example: less than < to &lt; Greater than sign > convert to &gt; Space conversion to &nbsp;

/indicates the root directory of the website;
.. Indicates the parent directory;
. Represents the current directory;
~ Special path, used only in server controls, is defined starting at the root of the app.

Convert virtual path to full path, absolute path
Virtualpathutility,toablolute ("~/a/b.html"); Convert to/website/a/b.html

The server-side control must submit the form with the Post method.

You can use ClientID to get the ID of the client control.
getElementById (' <% =textbox1.clientid%> ');
Not every server-side control has the same ID as the client's control ID, for example: The ID of the service-side control in the user-defined control (WEBUSERCONTRL.ASCX) will not be the same as the client's ID.

The server-side control label renders to <span> on the client, and if the Associatecontrolid property is set to TextBox1, the client renders <label for= "TextBox1" .../; Implement the associated control to get focus.

The literal control renders nothing on the client and is presented in plain text.
When you set its Mode property to encode, the control automatically implements Httputility.htmlencoder (string s) conversion, which is sometimes convenient and avoids xxs attacks.

TextBox control
1) Set TextMode property to Singleline, render as <input type= "text"/>
2) Set the TextMode property to multiline and render it as <textarea/>
3) Set TextMode property to Pasword, render as <input type= "password"/>
4) When the AutoPostBack property is set to True, the user focus leaves the textbox, which causes the post of the page, preferably using the __doPostBack JS method when submitting the form.

Written in the back: Knowledge Although the foundation, but practical, do not envy others to write a cool extreme JS effect to blindly follow suit. Three days fishing two days is not to be taken, the study of your insistence, no one's IQ high enough to learn will be, Yugong Yishan, Kuafuzhuiri spirit worthy of our study!

  • 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.