Cookies. Data in Cookies Which web site set the cookie Expiration date –DateTime data type –TimeSpan data type One or more pieces of data Keys Define.

Slides:



Advertisements
Similar presentations
Website Security ISYS 512. Authentication Authentication is the process that determines the identity of a user.
Advertisements

Cookies. Data in Cookies Which web site set the cookie Expiration date –DateTime data type –TimeSpan data type One or more pieces of data Keys Define.
Authenticating Users in an ASP.NET Application. Web Site Administration Tool From VS 2008, click Website/ ASP.Net Configuration to open Web Site Administration.
Shopping Cart Demo. Shopping Cart Search and display product information Add item to cart View cart contents Check out Note: WebsiteCart.
ASP.NET and ADO.NET. ASP.NET Server Controls Intrinsic Controls: These controls correspond to their HTML counterparts. –Ex. Textbox, listbox, button,
VB.NET Database Tools ISYS Net Applications OLE DB Provider OLE DB Data Source OLE DB Provider ODBC Data Source SQL Server Data Source SQL Server.Net.
Coding ADO.NET Objects: Connection, Command, DataReader.
Basics of ASP.NET. 2 © UW Business School, University of Washington 2004 Outline Installing ASP.NET and Web Matrix Data Types Branching Structure Procedures.
Website Security ISYS 512. Authentication Authentication is the process that determines the identity of a user. Web.config file – node Options: –Windows.
ASP.Net AJAX. AJAX Asynchronous JavaScript and XML: – JavaScript, Document Object Model, Cascade Style Sheet, XML, server-side script such as.Net, etc.
Web Site Security ISYS 512/812. Authentication Authentication is the process that determines the identity of a user. Web.config file – node Options: –Windows:
Coding ADO.NET Objects: Connection, Command, DataReader.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
Working with Session and Application Objects. Postback and Variables Variables declared in a web page including ADO.Net objects may be reinitialized and.
VB.NET Database Tools ISYS 573. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Introduction to Web Application Development with.Net and Web Service ISYS 350.
ASP.NET and ADO.NET. Bind the DataReader to a DataGrid Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\sales2k.mdb" Dim objConn.
Coding ADO.NET Objects: Connection, Command, DataReader.
Working with Session. Postback and Variables Variables declared in a web page including ADO.Net objects may be reinitialized and lose their values.
Introduction to VB.Net Internet Tools. Web Server Default directory –C:\InetPub\wwwroot –Computer lab: Zip drive dchao Default home page –Default.aspx,
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
Cookies. Data in Cookies Which web site set the cookie Expiration date –DateTime data type –TimeSpan data type One or more pieces of data Keys: A collection.
Website Security ISYS 512. Cookies Data in Cookies System.Web Which web site set the cookie Expiration date –DateTime data type –TimeSpan data type One.
Introduction to Web Service ISYS 512. Web Service XML Web Service Web services are classes that are stored on the web which can instantiate and use in.
ASP and HTML. Anchor Tag testAnchorTag Demo: ASPNet/ASPNETProdListSelf.ASPX.
Introduction to ASP.Net ISYS 350. ASP.NET ASP.NET is a server-side technology for creating dynamic web pages. ASP.NET allows you to use a selection of.
Chapter 9 – Validating User Input Dr. Stephanos Mavromoustakos.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Module 7: Validating User Input.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Christopher M. Pascucci.NET Programming: Forms & Controls.
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 3. 2 Overview Cookies Validation controls Client and server side validation Validation control examples.
Cookies. Data in Cookies Which web site set the cookie Expiration date –DateTime data type –TimeSpan data type One or more pieces of data Keys: A collection.
ASP.NET 2.0 Chapter 5 Advanced Web Controls. ASP.NET 2.0, Third Edition2 Objectives.
ASP.Net, Web Forms and Web Controls 1 Outline Web Controls Text and Graphics Controls AdRotator Control Validation Controls.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Validation and Rich controls 1www.tech.findforinfo.com.
Introduction to XML and Web Service ISYS 464. HTML vs XML HTML is a language specifically designed for displaying information in browser. It doesn’t carry.
1 Chapter 12 – Web Applications 12.1 Programming for the Web, Part I 12.2 Programming for the Web, Part II 12.3 Using Databases in Web Programs.
Lesson 12 Adding Validation To The Movie Database.
Website Security ISYS 512. Authentication Authentication is the process that determines the identity of a user.
ASP.Net and HTML. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data.
Module 4: Creating a Microsoft ASP.NET Web Form. Overview Creating Web Forms Using Server Controls.
Command Object’s ExecuteNonQuery Method ISYS 512.
VALIDATION CONTROLS.  Validation Controls are primarily used to validate, or verify the data entered by user into a web form.  Validation controls attempt.
ASP.NET Binding and an Introduction to Database Queries Please use speaker notes for additional information!
Session 6: Validating User Input. Outline Overview of User Input Validation Client-Side and Server-Side Validation ASP.NET Validation Controls Using Validation.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 User Input Validating.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
AJAX Asynchronous JavaScript and XML: –JavaScript, Document Object Model, Cascade Style Sheet, XML, server-side script such as.Net, etc. Partial refresh:
Shopping Cart Demo. Shopping Cart Search and display product information Add item to cart View cart contents Check out.
Coding ADO.NET Objects: Connection, Command, DataReader.
Coding ADO.NET Objects: Connection, Command, DataReader
ASP.NET and ADO.NET.
Unit 27 - Web Server Scripting
Web Services Introduction
Static and Dynamic Web Pages
PART 2.
Coding ADO.NET Objects: Connection, Command, DataReader
Database Handling Class and Service
ASP.NET and ADO.NET.
MIS 3200 – Unit 2.2 Outline What’s the problem with bad data?
Shopping Cart Demo.
Command Object’s ExecuteNonQuery Method
Presentation transcript:

Cookies

Data in Cookies Which web site set the cookie Expiration date –DateTime data type –TimeSpan data type One or more pieces of data Keys Define a new cookie: –Dim CookieCID as new HttpCookie(“cid”) Add to: Response.Cookies –Response.cookies.add(cookieCID)

Cookie’s Properties System.Web/HttpCookie –Name –Value –Expires To write a cookie: –Response.Cookies.Add(cookieObj)

Creating Cookies dim cookieCID as New HttpCookie("cid") dim cookieCNAME as new HttpCookie("cname") dim dt as dateTime=dateTime.now() dim ts as new TimeSpan(30,0,0,0) cookieCID.value=cid.text cookieCname.value=cname.text cookieCID.expires=dt.add(ts) cookieCname.expires=dt.add(ts) response.cookies.add(cookieCID) response.cookies.add(cookieCNAME) Note: The name(or key)of cookieCID is “cid” Demo: ASPNET/CookieForm.aspx

sub setCookie(Sender As Object, E As EventArgs) dim cookieCID as New HttpCookie("cid") dim cookieCNAME as new HttpCookie("cname") dim dt as dateTime=dateTime.now() dim ts as new TimeSpan(30,0,0,0) cookieCID.value=cid.text cookieCname.value=cname.text cookieCID.expires=dt.add(ts) cookieCname.expires=dt.add(ts) response.cookies.add(cookieCID) response.cookies.add(cookieCNAME) end sub Please enter customer ID: Please enter your name: This ID and name will be used to set your cookie.

Reading Cookies Dim custid as string Dim custName as string custid=request.cookies("cid").value custname=request.cookies("cname").value

Demo: CookieRead.ASPX sub page_load() cid.text=request.cookies("cid").value cname.text=request.cookies("cname").value cookieCount.text=cstr(request.cookies.count) Dim ckey As String For Each ckey In Request.Cookies.Keys Response.Write(ckey) Next end sub Note: SessionID

Using Cookie with DataReader dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\sales2k.mdb" dim objConn as new OledbConnection(strConn) dim strSQL as string dim objDataReader as oledbDataReader dim cid as string cid=request.cookies("CID").value strSQL="select * from webcustomer where CustID= '" & cid & "'" dim objComm as new OledbCommand(strSQL,objConn) objDataReader=objComm.executeReader() objDataReader.Read() session("cname")=objDataReader("CustName") response.write (" Welcome:" & objDataReader("CustName") & " ") Demo:ASPNET/CookieGreeting.aspx

Sending From an ASP.Net Page

Send a confirmation message. Send a document to a user as attachment. Forgot password?

Simple Mail Transport Protocol (SMTP) messages are text files. InetPub\MailRoot –PickUp directory: SMTP monitors this directory and sends any messages found in this directory. –Drop: Incoming messages received by SMTP are written to this directory. –BadMail: If an cannot be delivered or returned to the sender it is moved to this directory.

ASP.Net Classes SmtpMail class –System.Web.Mail Methods: –Send(From, To, Subject, messageText) SmtpMail.Send(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text) –Send(System.Web.Mail.MailMessage) Demo: –SendMail.aspx –Import system.web.mail

Using MailMessage Class to Set Properties properties: –Attachments –Bcc –Body –BodyFormat Text or Html –Cc –From –Headers –Subject –To

Demo: ForgotPassword.ASPX Dim Address As String Address = TextBox1.Text objConn.Open() strSQL = "select * from users where = '" & Address & "'" Dim objComm As New OleDbCommand(strSQL, objConn) objDataReader = objComm.ExecuteReader() If Not objDataReader.Read() Then Response.Write("We don't have your record" & " ") Else Dim objMsg As New MailMessage() objMsg.From = objMsg.To = Address objMsg.Subject = "Your password" objMsg.Body = "Your password is: " & objDataReader("password") SmtpMail.Send(objMsg) Response.Write(" Your password is sent to your account ") End If

UpLoading Files

File Field Control HTML File Field Control: –Composite control with a textbox and a Browse button. Convert a HTML File Field control to a server- side control: –Visual Studio: Add a File Field control from the HTML tab. Point to and right click the control and choose Run As a Server Control (This will add the Runat=“Server” attribute to the File Field control).

Accessing the Uploaded File FileFieldControlName.PostedFile –This is a System.Web.HttpPostedFile class Properties: –FileName: This name contains the path of the posted file.’ –Contentlength –ContentType Method: –SaveAs – this method save the posted file on server. Demo: Upload.aspx

Save Uploaded File Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim FileName As String Dim strFilePath As String = "c:\inetpub\wwwroot\images\" FileName = upLoadFilePath.PostedFile.FileName.Substring(upLoadFil ePath.PostedFile.FileName.LastIndexOf("\") + 1) strFilePath = strFilePath & FileName upLoadFilePath.PostedFile.SaveAs(strFilePath) response.write("File: " & fileName & " is saved on server") End Sub

Insurance Claim Example Uploading claim pictures for insurance cases. Each case may have many pictures. Database: –CaseTable: CaseID, CaseDate, Agent –CasePics: CaseID, PicPathName Each picture is named: CaseID + PictureName and saved in folder: Images Create a web page with a dropdown list of CaseID, a File Field control to choose file, and a upload button. The uploaded picture will be saved in the Images folder and a record will be entered in CasePics file. Demo: Insurance/UploadPic.aspx

Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim CaseID As String Dim FileName As String Dim strFilePath As String = "c:\inetpub\wwwroot\images\" FileName = upLoadFilePath.PostedFile.FileName.Substring(upLoadFilePath.Poste dFile.FileName.LastIndexOf("\") + 1) CaseID = ListBox1.SelectedItem.Text FileName = CaseID & FileName strFilePath = strFilePath & FileName upLoadFilePath.PostedFile.SaveAs(strFilePath) Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\InsurancePic.mdb" Dim objConn As New OleDbConnection(strConn) Dim strSQL As String = "Insert Into CasePics Values ('" & CaseID & "','" & strFilePath & "')" Dim objComm As New OleDbCommand(strSQL, objConn) objConn.Open() objComm.ExecuteNonQuery() End Sub

Calendar Properties: –SelectionMode –SelectedDate –SelectedDates Event: –SelectionChanged

AdRotator AdRotator displays images in an advertisement file which is an XML file with properties of images to display.

Advertisement File Example images/cake.gif default.aspx Great Cake 1 TestAd images/earth2.gif default.aspx Beautiful Earth 1 TestAd

Advertisement Properties ImageURL NavigateURL: The page you go to when you click an image. AlternateText: Text displayed for browsers do not support image. Keyword: Categorize advertisements, can be used with AdRotator’s KeyWordFilter property. Impressions: The relative frequency a particular advertisement should be shown.

Validation Controls CompareValidator: (Collating sequence comparison) –Properties: ControlToValidate ErrorMessage Operator: Greater, LessThan, … ValueToCompare RangeValidator: –MaximumValue, MinimumValue RequiredFieldValidator

CustomValidator: Checks the user’s data entry using validation logic from a customer method you write processed on the server or the client. Use the ClientValidationFunction property to call a client-site validation script. For server-site validation, this control raises an OnServerValidate event where you can write an event procedure to validate data. The OnServerValidate event is triggered by: Page.IsValid statement