Saturday, July 14, 2007

ASP.NET and dotNet Framework XML Web Services

1. Using HTML to create Web sites.
A. All static. Requires Web Master to continually update pages
B. Very difficult to deal with databases
3. Using ASP: Active Server Pages
A. The Web server can run script locally and then return HTML on the fly
1. Good for working with databases
2. But script language was very limited
B. Old ASP = one file a jumble of HTML, server side and client side code.
1. ASP.Net can still use script but it goes in the HTML view.
4. Using ASP.NET and the dotNet Framework
A. Design (HTML) and code (VB) are separate files.
B. Web applications can be designed with a real programming language.
C. Can use any language you feel comfortable with.
5. Login Form from book: Page 102
A. Tips: When creating a new project
1. Delete the default Webform and add a new one with your name
2. Set the new form pagelayout properties to flow not grid
B. The .aspx file is just the layout information
C. Code is separate in the code-behind file .aspx.vb
1. Very nice: Can update your code without fooling with the layout…live.
D. When you trigger an event (like a button click)
1. The page does not change locally. It posts back to the server
2. The server responds by resending the page with requested changes.
a) ASP.NET takes care of re rendering the controls with your “entered” data in it….old days you had to recode all this..(so you just didn’t do it.)
3. NOTE this saves you hours of work compared to ASP.
E. Dim x,y as integer ‘works
F. Dim x as integer = 5 ‘called dim and initialize.
1. Handy but does not let you trap an error on this line.
6. ASP.NET
A. Technologies that make up ASP.NET
1. Web Forms: For User Interaction
a) Used to layout server controls
2. Server controls
a) Still supports HTML controls
3. Validation controls: Used to validate user input.
4. Web Services
a) For interaction with other programs.
B. All use the Code-Behind concepts
7. XML Web Services: No User Interface
A. A function that is called across Internet
B. Programmatically request data or action across the net.
1. And the remote side triggers and returns data.
2. As long as both sides agree on the SOAP method of packaging requests and responses then ASP Web Services
C. Always returns an XML string
D. Servers Publish or Expose and clients Consume Web Services
E. Easy concept:
1. You create Public functions
2. These are exposed to the Web with the tag
3. The compiler does the rest!
F. Support files automatically created.
1. .VS Diso = discovery file that lists the Web Services on the Web Site
2. .WSDL = Web service description language. Methods available and parameters
8. Web Forms: User Interface to hold controls
A. They are for server side only (the user never “sees” this form)
1. In runtime aspnet_isapi.dll will render the aspx page as HTML
B. Two files: .aspx & aspx.vb
1. .ASPX will be the web page the user will surf to.
a) .vb file will be used by the compiler to create the application DLL
b) .cs if using C
2. (.vb ) The Code behind always runs at the server
3. If you want client side script you have to put it in the HTML design view.
9. Web Form Controls:
A. Come in two flavors:
1. Server Controls (green triangle) found in Server Control Toolbox
a) controls that tell aspnet_isapi.dll to return themselves as HTML
2. HTML (like old ASP/HTML controls) and live on HTML controls toolbox
a) Standard HTML controls. No server side processing.
10. HTML Controls (old)
A. HTML controls are standard HTML controls
1. They are returned to the browser as is.
B. Used for compatibility with existing pages
C. Rare in VS.NET
11. Web Form Server Controls (note the green handle = Web Server Control)
A. Place holders = Little “code generators”…but you never see the code.
B. In HTML view: Note the ASP: tag in front of the name of the control
1. :tag that triggers IIS to call .NET to return standard HTML controls at run time but configured dynamically …. The way you want it at that moment.
C. During design they appear for your design benefit.
1. Best is to work in Flow page layout mode
D. Output is based upon the type of browser detected
1. Supports various DHTML as necessary
2. But you don’t have to worry about it.
E. Field Validator Controls
1. Java script code generator
2. Perform client side (no round trip) user validation
a) Takes the place of the client side Java script we had to write for ASP
b) Even if client does not support Java…server will validate.
12. How the Web forms work (key point…it all happens on the server!)
A. User requests an .aspx page…the associated DLL from bin folder is loaded and processed on the server
B. Key point… On the browser side this is a simple HTML post page.
C. Once the post on aspx is triggered the following happens on the server.
D. Init event fires (helps manage state) but you do not program here.
E. Load event is triggered: Important!
1. Very common. If you click on a button that triggers a “postback” the page must redisplays itself…this is a round trip to the server.
2. Although the event is triggered on the local browser (ie a click) the server has to process the event associated with the click…= PostBack
3. This may require you to check the Page.IsPostBack property to see if this is the first time through.
F. If it is a post back then all the change events that were batched up on the client are triggered
1. These batched events will trigger in random order…careful
G. If it is a post back…then the server raises the event that got triggered to force the postback
1. Some controls force a post back when you click on it. (buttons)
2. Other controls (like the listbox) must set AutoPostBack = True to force a post back on the click
13. How “IIS” Objects Work: Used to be the core of ASP programming
A. Response Object: Place data into the HTML stream as leaves the server
1. Used to force output (as if you were typing the page)
2. Response.Write(“this will be send to the browser”)
3. Response.Cookies to Create cookies
B. Request Object: Read data coming from the browser
1. Used to read information coming from the browser
a) Request.Cookies to read cookies.
2. Input fields or URL information
a) Request.Form and Request.QueryString
C. Session Object: User (session specific) variables stored on the server
1. In ASP we avoided these because they clogged the server
2. In ASP.NET they are managed by the Framework more efficiently
D. Application Object: Variables used by all users one application…
1. IE connection string
2. Better in ASP.Net than ASP
E. Server Object: Provides information about current state of server
1. Server.MapPath(“Hello.txt”) returns the exact path to that file on the current server.
2. Provides access to the SERVER_VARIABLES. (ip addresses etc)
F. Global.asax: Like the global.asa in ASP but more events
1. Holds events that get triggered site wide
2. Application_Start and _End (when IIS starts and ends)
3. Session_Start and _End (when a user opens their first asp page)
4. ASP.NET adds about a 14 other Application_ events
a) Used to trigger events as ASP.NET processes Web Forms pages
14. Custom Controls and User Controls
A. Custom controls are objects like the ones in your toolbox
1. We will not be creating these in this class
B. User Controls are similar to #Include files
1. You create a page of code and save it.
2. Then drag the “Control” onto a page and it acts as if you typed it there
3. Great for standardized headers, footers and library code.
C. Easy to create
1. Create a new form and remove all the code
2. Insert just the stuff you want to appear as an include file
3. Change the extension from .aspx to .ascx
4. Drag it on to any other web form…
D. You use these extensively in your Final Project