[ASP.NET Tutorial] I. Web Foundation

xiaoxiao2021-03-06  22

Note: This tutorial is based on .NET Framework 1.1, use C # language description, and assumes readers to understand HTML and C # syntax, JScript client scripts, know the basic IIS configuration. These do not belong to this tutorial, please refer to the relevant books or tutorials.

HTTP protocol

In addition to TCP / IP protocol, HTTP can be said to be the most important and use the most network protocol. This section briefly introduces the working principle of the HTTP protocol.

Suppose now has an HTML file: http.html, stored on the web server, its URL is

Www.myweb.com/http.html, the file content is:

HTML code:

http.html </ title></p> <p></ hEAD></p> <p><body></p> <p>Hello, http</p> <p></ body></p> <p></ html></p> <p>Now, a user accesses the address by IE, IE first converts the domain name of this address into an IP address through the DNS, and then passes through a port of the web server (default is 80, not 80 to add ": port": port ", For example</p> <p>Www.myweb.com:81) Connect, then transmit a similar information like this to download files like this (using FlashGet, etc.):</p> <p>Code:</p> <p>Get / http.html http / 1.1</p> <p>Host: www.myweb.com</p> <p>Accept: * / *</p> <p>User-agent: mozilla / 4.0 (compatible; msie.6.0; windows NT 5.1)</p> <p>Pragma: no-cache</p> <p>Cache-Control: No-cache</p> <p>Connection: Close</p> <p>[Blade]</p> <p>The first behavior request content, indicating that the resource request resources to the server via the GET method, / http.html is the request resource name, and HTTP / 1.1 represents the use of the HTTP protocol, version 1.1. Then the next few lines are called the header of the request information, which describes some other information requested, such as client browser identification, and the like. The last space indicates the end of the request.</p> <p>When the web server receives the request, the server checks if the requested resource is valid, and whether there is corresponding permissions. If there is no problem, the server will return to the following HTTP response information:</p> <p>Code:</p> <p>HTTP / 1.1 200 ok</p> <p>Server: Microsoft-IIS / 5.0</p> <p>Date: Thursday, March 31, 2005 17:15:23 GMT</p> <p>Content-Type: Text / HTML</p> <p>Content-Length: 88</p> <p>[Blade]</p> <p><html></p> <p><HEAD></p> <p><title> http.html </ title></p> <p></ hEAD></p> <p><body></p> <p>Hello, http</p> <p></ body></p> <p></ html></p> <p>The "200" of the first line is a state code, indicating that the server successfully completed the request, if it is not successful, the other status code is returned. Content-type indicates the returned data type, and content-length indicates the returned data length. The blank representation header ends, the next is the data content returned by the browser, here is the file content of http.html, the browser parses the HTML source code, rendering the web page to the user, and completes a success here. HTTP communication.</p> <p>The above content is the basis of web communication. Like the Windows message mechanism, you may not use it, but you have to know it, you have to know which low-level contents have hidden in those advanced things, so that you understand and use those Advanced things have a very helpful help :). 2. HTML FORM</p> <p>The front http.html file is a simplest static HTML page, but as a web program, it is too simple, it does not accept user input, always display the same content. We need to be able to return the corresponding data according to user input.</p> <p>Look at the HTML code below:</p> <p>HTML code:</p> <p><html></p> <p><HEAD></p> <p><title> form.html </ title></p> <p></ hEAD></p> <p><body></p> <p><form method = "get"></p> <p><Input Type = "text" name = "p" /></p> <p><Input Type = "Submit" value = "submit" /></p> <p></ form></p> <p></ body></p> <p></ html></p> <p>Observe this code, there is an HTML Form, which includes between <form> and </ form>, there is a submission button (<input type = "submit" value = "submit" />) When you click on this button, the browser submits all the inputs in the HTML Form to the web server, the Method property of the Form tag specifies the submission, here is GET, this GET corresponds to the GET request method in the HTTP request, the input in the Form Attached to the URL in the way in the query string, enter a string in the text box, such as "form", then observe the browser's address bar, will become similar</p> <p>http://www.myweb.com/form.html?p=form, this is because the browser issues such a GET request:</p> <p>Code:</p> <p>Get /formed.html?p=form http / 1.1</p> <p>...</p> <p>...</p> <p>[Blade]</p> <p>If the <form> tag is "POST", that is, the browser sends the request using the POST method. When using the POST method, the user's input is not transmitted by the URL, but the browser places the content in the POST request. The header is sent to the web server:</p> <p>Code:</p> <p>Post /form.html http / 1.1</p> <p>...</p> <p>...</p> <p>Content-Type: Application / X-WWW-FORM-URLENCODED</p> <p>Content-Length: 6</p> <p>[Blade]</p> <p>P = Form</p> <p>The web server can then process the user input by accessing the data sent by the POST request.</p> <p>The browser sends the user into the web server using the GET or POST method, which is called "postback". This concept is quite important, often involving faster in a web application.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-39919.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="39919" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.034</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'P5aysEi14_2FmseSRdFKF5Liq8Xw6B3qNo8e5cnHIWZKpOQBgtMiX1593Srea8lhdcxisetPBBB49WqG_2Fm4jsbHA_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>