1 / 9

ASP application

ASP application. Combination of web pages files, handlers, modules and executable code that can be invoked from a virtual directory on a web server Contains: Aspx files: user interface + code Ascx files: user controls Global.asax: define global variables & react to global events

noel
Download Presentation

ASP application

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP application • Combination of web pages files, handlers, modules and executable code that can be invoked from a virtual directory on a web server • Contains: • Aspx files: user interface + code • Ascx files: user controls • Global.asax: define global variables & react to global events • Vb or cs files: code behind

  2. Stages in ASP.NET request Web request IIS Is the file registered to ASP.NET? Handle the request internally or pass it to another service No Yes ASP.NET Has application instance been created? Instantiate the application, create Global variables and fire global events NO Yes Has the requested page been complied? Compile and cache page NO Yes Instantiate the page, fire page events and run event handling code Render page to HTML one control at a time Web response

  3. Page Class properties • IsPostBack: Boolean showing if this is the first time the page is run • EnableViewState: Boolean to enable/disable maintaining page state • Controls: Collection of controls in the page • Request: reference to HttpRequest object (contains information about the current web request) • Response: Reference to HttpResponse object (set the web response) • Application and Session: Collections to hold information on the server

  4. Page • Directives: set pre-processor options (processed before any code) • Post back is when the page calls itself again when the user interacts with a server control • The page and its content are sent to the server • To connect the code-behind file to ASP.NET user interface file, put attribute [Inherits=“class name”] and [src=“code-behind file name”] in the page directive

  5. HttpRequest Class • All information related to a client request • When a form is submitted, data can be retrieved as collection • QueryString: collection of data passed using “Get” • Form: collection of data passed using “Post” method • Server variables: collection of Http headers • Browser: reference to HttpBrowserCapabilities object (type, version, platform, frames, cookies, tables, Javascript, vbscript, win32, ..) • Cookies: Collection of cookies • URL/ UrlReferrer

  6. HttpResponse Class • Send information to the client • Write (string): Output to buffer • WriteFile (filename): Send file to client • Redirect (URL): Transfer user to another page • Cookies: Collection of cookies sent to client • BufferOutput: Bolean to collect the output in a buffer file before sending to client

  7. Writing and Reading Cookies • Writing cookies: Dim c As HttpCookie c = New HttpCookie("writecookiefile") c("name") = "ahmed5667" c("id") = "123677" Response.Cookies.Add(c) c.Expires = DateTime.Now.AddMonths(2) • Reading cookies: Dim c As HttpCookie c = Request.Cookies("writecookiefile") TextBox1.Text = c("name") TextBox1.Text &= " " & c("id") OR For Each i In Request.Cookies Response.Write("<BR>" + i + "<BR>") Response.Write(Request.Cookies(i).Value) Next

  8. Session & Application • Session: A collection object for every user accessing the application at a particular point of time. • SessionID: a unique number to identify each user • Application: One common collection object for all users and all web pages of the application

  9. Application • Global events that apply to the whole application are stored in a file called Global.asax • Application start • Application Shutdown • Session Start • Session End • Application Error

More Related