Active Server Pages ASP.Net - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Active Server Pages ASP.Net

Description:

Make the new directory virtual and enable annonamous access ... Traditional script, e.g.: Javascript or Vbscript. Embedded ASP.Net server controls ... – PowerPoint PPT presentation

Number of Views:428
Avg rating:3.0/5.0
Slides: 20
Provided by: jimfa
Category:

less

Transcript and Presenter's Notes

Title: Active Server Pages ASP.Net


1
Active Server PagesASP.Net
  • Jim Fawcett
  • CSE686 Internet Programming
  • Summer 2005

2
Important Note!
  • You cant run Asp.Net applications those with
    .aspx extensions from the current college
    server. It does not have .Net installed.
  • I will be running .Net applications from a new
    server that does have .Net installed and will
    become the college server sometime soon.
  • You can run all the applications from the lecture
    5 web page, as that links to the new server.

3
Moving Your Projects
  • Visual Studio, by default, will build Asp.Net
    applications in two files
  • Web site files are placed in a folder with the
    project name under C\inetpub\wwwroot.
  • Your solution and project files go in a folder
    with the project name underC\Documents and
    Settings\YourAccountName\My Documents\Visual
    Studio Projects\
  • You can move the website folder into any parent
    directory you wish as long as you do two things
  • Make the new directory virtual and enable
    annonamous access
  • Edit the WebApplication.csproj.webinfo to provide
    the correct url.
  • Make sure the Application name shows in the
    virtual directory properties on the Virtual
    Directory tab. You may have to hit Remove and
    Add.

4
Changing Project Virtual Directories
5
Server-Side Programs
  • You can run any .Net executable that resides in a
    virtual directory simply by requesting it from a
    browser
  • http//localhost/http//localhost/AspApps/PickCour
    se/PickForm.aspx
  • Provided that directory permissions allow this.
  • On Windows platforms most server-side processing
    takes the form of Active Server Page (ASP)
    applications or ASP.Net applications.
  • Note that the examples Ive placed on the college
    server will not run from there, as that server
    does not have .Net installed.
  • To run the examples, just FTP the code folder to
    any directory on your local machine, in Windows
    Explorer right click on the folder, select
    properties, and select web sharing.
  • Now you can open, for example, drives.aspx with
    the browser URLhttp//localhost/lecture5/drives.
    aspx

6
Traditional ASP
  • Traditional (pre .Net) ASP provides interpreted
    application scripts running in the memory space
    of the IIS web server.
  • A traditional ASP page consists of a mix of HTML,
    sent directly to the requesting browser and
    Javascript or Vbscript executed on the server,
    usually to generate html for display or interact
    with a backend database.
  • Traditional ASP uses a set of standard server
    side COM objects and can use custom COM objects
    as well.
  • Deploying custom COM objects to remote servers
    has been a major problem.

7
Server-Side Objects
  • Traditional ASP provides seven objects used for
    server-side programming
  • Application
  • starts when IIS starts and runs until IIS shuts
    down
  • ASPError
  • ASPError object is returned by Server.GetLastError
    (), and has the propertiesSource, Category,
    File, Line, Description, ASPDescription
  • ObjectContext
  • Access to COM objects
  • Request
  • Provides methodsForm(), QueryString(),
    Cookies(), ServerVariables()
  • Response
  • Provides methodsWrite(), Clear(), End(),
    Flush(), Redirect(), Buffer, Expires,
    IsClientConnected(), PICS()
  • Server
  • Provides methods Execute(), Transfer(),
    MapPath(), URLEncode(), HTMLEncode(),
    GetLastError()
  • Session
  • starts when a user requests first page and ends
    with a timeout

8
ASP .Net
  • ASP.Net supports the traditional style, but adds
    processing power of compiled C and a pervasive
    object model.
  • We can create user-defined classes in C and use
    them on ASP pages. Any .Net language can be used
    this way.
  • Web controls are based on CLR objects. Control
    state is sent back and forth between client and
    server.
  • An ASP.Net page can easily be turned into a
    server control that can be used on any other ASP
    page.
  • ../lectures/cse686codeL5.htm

9
ASP Environment
10
ASP Page Contents
  • An ASP page can contain
  • Instructions for the server
  • HTML content, intended for the client
  • Code in C, VB, Jscript.Net. The Code will
  • generate HTML for client
  • get or send data to a database on this or a
    remote server
  • interact in some way with the servers file
    system
  • Traditional script, e.g. Javascript or Vbscript
  • Embedded ASP.Net server controls
  • Means to collect information from, and present
    information to, client
  • Control state is preserved in transactions
    between client and server
  • Traditional HTML controls
  • Also manages information between client and
    server. Preserving state requires more work on
    programmers part.

11
ASP Applications
  • You can build an ASP application using notepad to
    create an aspx page, a C code page, and a
    web.config file.
  • c\su\cse686\code\AspApps\BasicAsp
  • http//localhost/AspApps/BasicAsp/PickAgain.aspx
  • Most often, you will build ASP solutions using
    Visual Studio.net.

12
ASP.Net Application Files
  • An ASP Application generated by the Visual
    Studio.Net application wizard consists of
  • A solution in the local directory you chose for
    building the app
  • A set of files in a virtual directory on your
    development machine. When the application is
    complete you will simply copy these files to the
    web server you want to use to deploy the
    application.
  • c\su\cse686\code\aspapps\pickCourse
  • http//localhost/AspApps/PickCourse/PickForm.aspx

13
ASP Application Files (continued)
  • WebForm1.aspx
  • An ASP page providing the user interface for the
    application
  • WebForm1.aspx.cs
  • A C WebForm, with structure somewhat like a
    WinForm
  • Web.config
  • Allows you to set debug tracing and other session
    related properties
  • AssemblyInfo.cs
  • Holds assembly deployment information

14
Server Controls
  • ASP.Net provides a number of Web controls based
    on HTML elements and HTML controls.
  • Label, Button, TextBox, DropDownList, ListBox,
    Image, CheckBox, RadioButton, RadioButtonList,
    Calendar, Table, Panel, DataList, DataGrid,
  • These controls have state which is marshalled
    between client and server in a hidden ViewState
    variable.
  • Events, like button clicks, that happen on the
    client side, are marshalled back to the server to
    trigger event handlers in C, processed on the
    server.

15
Design View
16
ASPX Code View
17
C Code View
18
Lets Build an Application
  • Create an ASP.Net Application, using C
  • Right click on form and set its layout property
    to flow layout.
  • Pull a TextBox, Button, and Label onto the form.
  • Switch to HTML view and put a couple of ltbrgt tags
    between each of these controls.
  • Double click on the form to generate a Page_Load
    event handler and we will put some code there.
  • Double click on the button and well also put
    some code there.
  • Run the application.

19
References
  • Programming Microsoft .Net, Jef Prosise,
    Microsoft Press, 2002
  • ASP.NET Unleashed, Second Edition, Stephen
    Walther, SAMS, 2004
  • ASP.Net, Tips, Tutorials, and Code, Mitchell, et.
    al., SAMS, 2002
  • More examples (a lot in Visual Basic.Net, some in
    C) than most of the other books available on
    ASP.
  • www.gotdotnet.com has some interesting tutorial
    material on ASP.Net.
Write a Comment
User Comments (0)
About PowerShow.com