Académique Documents
Professionnel Documents
Culture Documents
Net
IT 4203 Advanced Web Development
Overview
Dynamically generating content Processing incoming HTTP messages and user data
Web servers and web clients communicate through HTTP messages (protocols)
Request: getting the resource, with user data submitted to server. The server will process user data. Response: generating content and send it back to browsers.
3
Most of the HTTP response processing functionalities are provided through the System.Web.HttpResponse class
The methods and properties of the HttpResponse class are exposed through the Response property of the Page class (ASP.Net web forms). Response is a built-in object and can be directly used in .aspx pages and .aspx.cs code-behind pages.
Response.Write
Expression
An expression can be a variable, formula, object property, string concatenation, method with return value, or anything that returns a value
<% String title = Hello; %> <%= Title%>
Expression code block is equivalent to Response.Write(), and are mixed with static content
6
2.
3.
String.Format()
Response.Write(String.Format(<h1>,0-</h1>, title));
7
StringBuilder.Append()
System.Text.StringBuilder
String title = Hello; StringBuilder html=new StringBuilder(); html.Append(<h1>); html.Append(title); html.Append(<h1>); Response.Write(html.ToString());
Most of the HTTP request processing functionalities are provided through the System.Web.HttpRequest class
The methods and properties of the HttpRequest class are exposed through the Request property of the Page class (ASP.Net web forms). Request is a built-in object and can be directly used in .aspx pages and .aspx.cs code-behind pages.
Get
User data is sent as part of the request URL; no content in request message body Triggering actions: address bar (in browser), link, form, User data is sent in the request message body Triggering actions: form,
Post
URL Parameter
URL parameter
http://www.bing.com/search?q=web&form=QBLH
Request.QueryString
QueryString Property wraps URL parameters to collections of parameter names and values
User input
http://www.google.com/search?q=asp
http://www.newegg.com/Product/Product.aspx?Item=N82E16827135204 http://www2.cis.gsu.edu/cis/people/display.asp?pk=3
http://forum.java.sun.com/category.jspa?categoryID=20 http://cis3270.jackzheng.net/index.jsp?page=schedule
Settings/configuration
http://finance.yahoo.com/q/bc?s=MSFT&t=5d&l=on&z=l&q=l http://msdn.e-academy.com/elms/Storefront/Home.aspx?campus=gsu_cis
11
Textbox: <input type=text> Password: <input type=password> Text area: <textarea> Combo box: <select> List: <select multiple=multiple> Checkbox: <input type=text> Radio button: <input type=text> Hidden: <input type=hidden> Buttons : Submit, Reset
More details
http://www.tizag.com/htmlT/forms.php
13
Get
Form data are encoded as URL parameters Using Request.QueryString to process form data Using Request.Form
14
Post
Request.Form
15
Input Validation
Use server side programming capability to validate user inputs Additional request/response cycles Need special handling to keep user data in the form
Use JavaScript to check form data before the form is submitted to the server side No additional transmission between server and browser <form onsubmit=javascript: return checkForm()>
checkForm() is a JavaScript function that either returns true or false, depending on validation results
16
Brower type Client host and IP address URL information Requested resource information Referrer
17
Summary
Key concepts
HTTP request and response URL parameter HTML form, method, action HTML form element name and value attribute
Key skills
Use Request (System.Web.HttpRequest) and Response (System.Web.HttpResponse) object in ASP.Net pages. Create dynamic content and mix them with static content. Get user input through URL parameters or HTML forms.
18
More Resources
System.Web.HttpRequest
http://msdn.microsoft.com/enus/library/system.web.httprequest(v=VS.90).aspx
System.Web.HttpResponse
http://msdn.microsoft.com/enus/library/system.web.httpresponse(v=VS.90).asp x
19