BIT 286: Web Applications Lecture 10 : Thursday, February 5, 2015 ASP.Net Form Submission.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Using EBSCOs Search Box Builder Tool Tutorial. Would you like to promote your EBSCOhost resources by adding an easy-to-use search box to your website?
ADABAS to RDBMS UsingNatQuery. The following session will provide a high-level overview of NatQuerys ability to automatically extract ADABAS data from.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Introduction to MVC Action Methods, Edit View, and a Search Feature NTPCUG Dr. Tom Perkins.
OpenCMS and the MSASS Website. A Note on Terminology Locking a file for editing: No lockNOT locked You have write/edit access Someone else has write.
Introduction to Online Data Collection (OLDC) Community Based Abstinence Education September, 2009.
Logging In Go to web site:
COMP 321 Week 12. Overview Web Application Security  Authentication  Authorization  Confidentiality Cross-Site Scripting Lab 12-1 Introduction.
WebDFS Budget Amendment and Personnel Processing.
U:/msu/course/cse/103 Day 23, Slide 1 Review of Day 22 What query did you use to search for an actor by name? –Return matches.
WEB SECURITY WORKSHOP TEXSAW 2013 Presented by Joshua Hammond Prepared by Scott Hand.
Blackbaud Web Purchasing Training Session 1. Agenda What is Blackbaud Web Purchasing? How to login to Blackbaud Web Purchasing Create a purchase requisition.
Public Key Encryption An example of how a bank might accomplish encryption.
 A cookie is a piece of text that a Web server can store on a user's hard disk.  Cookie data is simply name-value pairs stored on your hard disk by.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Dataface API Essentials Steve Hannah Web Lite Solutions Corp.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
JavaScript & jQuery the missing manual Chapter 11
Session 5: Working with MySQL iNET Academy Open Source Web Development.
CSC 2720 Building Web Applications Cookies, URL-Rewriting, Hidden Fields and Session Management.
Server-side Scripting Powering the webs favourite services.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC - Models.
Blackbaud Web Purchasing Training Session 1. Agenda What is Blackbaud Web Purchasing? How to login to Blackbaud Web Purchasing Create a purchase requisition.
Creating Effective School and PTA Websites Sam Farnsworth Utah PTA Technology Specialist
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Universiti Utara Malaysia Chapter 3 Introduction to ASP.NET 3.5.
Introduction to Entity Framework Part 2 CRUD Scaffolding Tom Perkins NTPCUG.
JavaScript – Quiz #9 Lecture Code:
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
1 What to do before class starts??? Download the sample database from the k: drive to the u: drive or to your flash drive. The database is named “FormBelmont.accdb”
Creating PHPs to Insert, Update, and Delete Data CS 320.
Building Secure Web Applications With ASP.Net MVC.
Basic & Advanced Reporting in TIMSNT ** Part Three **
Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.
Microsoft FrontPage 2003 Illustrated Complete Integrating a Database with a Web Site.
OFFICE OF INFORMATION TECHNOLOGY Frevvo Training MIDDLEWARE AND HIGH PERFORMANCE COMPUTING OFFICE OF INFORMATION TECHNOLOGY, ENTERPRISE SYSTEMS FLORIDA.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
ICM – API Server & Forms Gary Ratcliffe.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
A user guide to accessing, reviewing and contributing to the Online Registry System.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
ASSIGNMENT 2 Salim Malakouti. Ticketing Website  User submits tickets  Admins answer tickets or take appropriate actions.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
CSRF Attacks Daniel Chen 11/18/15. What is CSRF?  Cross Site Request Forgery (Sea-Surf)  AKA XSRF/ One Click / Sidejacking / Session Riding  Exploits.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
LOGIN FORMS.
© 2015 Eaton. All Rights Reserved.. Supplier Registration and Access.
WEB SECURITY WEEK 1 Computer Security Group University of Texas at Dallas.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
BIT 286: Web Applications ASP.Net MVC. Objectives Applied MVC overview Controllers Intro to Routing Views ‘Convention over configuration’ Layout files.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC - Models.
Jim Fawcett CSE686 – Internet Programming Spring 2014
Jim Fawcett CSE686 – Internet Programming Spring 2012
Assess Survey Invitations
Cross-Site Forgery
PHP / MySQL Introduction
04 | Customizing Controllers
Controllers.
Cross Site Request Forgery (CSRF)
Presentation transcript:

BIT 286: Web Applications Lecture 10 : Thursday, February 5, 2015 ASP.Net Form Submission

Examining Edit Form submission started/introduction/examining-the-edit-methods-and-edit-view 2

Examining Edit: First Visit: Controller  Controller method for first time (non-POST) visit:  Notice how similar this looks to the Details page // GET: Movies/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Movie movie = db.Movies.Find(id); if (movie == null) { return HttpNotFound(); } return View(movie); } 3

Examining Edit: First Visit: the View  ViewBag.Title = "Edit"; } (Html.BeginForm()) Movie 4  The rendered HTML Edit Movie

XSRF/CSRF Cross-Site Request Forgery  Good explanation at ASP.Net Good explanation at ASP.Net  Essentially, you visit Web Site #1 and legitimately log in  The browser keeps the authentication info until the web browser process exits  The browser also automatically re-sends the authentication info whenever you visit that site.  This is very convenient when you’re on Web Site #1  You go to Web Site #2, which attempts to access Web Site #1  E.g., Web Site #2 creates it’s own form, whose action is to submit to Web Site #1  Your browser conveniently re-sends the authentication info along with the form  Web Site #2 can now act as you on Web Site #1  This is the ‘cross site’ part  I’ve heard that this can be done even by ads served to you on pages you trust.  I’d be surprised if Google, MS, etc, would let this happen, but you don’t control which ad- serving arrangements are used by the websites you visit. 5

XSRF/CSRF Cross-Site Request Forgery  We can combat this with anti-forgery tokens  Web Site #1 will generate a random number and put it into a hidden field in the form it sends to you  (This is the anti-forgery token)  Web Site #1 will check (when you post that form back) that the number in your form matches the one it sent you  This prevents Web Site #2 from making up it’s own form  Because it can’t generate the same random numbers as Web Site #1 6

Examining Edit: First Visit: the View  Edit.cshtml "", new = "text-danger" => => model.Title, htmlAttributes: new = "control-label col-md-2" => model.Title, new { htmlAttributes = new = "form-control" } => model.Title, "", new = "text-danger" }) to List", Scripts } 7  The rendered HTML Title

Examining Edit: POSTing the edits: Controller  Controller method for POST visit: [HttpPost] // Only used for HTTP POST requests; HTTP Get is the default [ValidateAntiForgeryToken] // from View public ActionResult Edit([Bind(Include = "ID,Title,ReleaseDate,Genre,Price")] Movie movie) { if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(movie); } 8

Examining Edit: POSTing the edits  Controller method for POST visit: public ActionResult Edit( [ Bind(Include = "ID,Title,ReleaseDate,Genre,Price") ] Movie movie ) { /* Snip */  Include is the list of properties (data fields) to extract from the form  Other fields are left blank in the movie object, even if they’re present in the form  These data fields are filled in for you, automatically, on the movie object. 9

Security Risk: Overposting  Normally you’d never put extra properties in your form….  …but hackers might download & save a copy and add stuff.  For example, let’s say that the ‘Edit User’s Unimportant Account Info’ page normally just lets you update your firstname, last name, nickname, picture, etc, etc.  But does NOT let you change the password  You can go to that page, select ‘Save As’ in your browser, edit the form locally to also include a new password for the user, and then submit the form.  If you blindly bound the movie object to ALL fields, and saved the whole object you’d update the password  The ‘Include’ attribute allows you to only bind to some of the fields  Also a good explanation at MSDNgood explanation at MSDN 10

Search started/introduction/adding-search 11

Tutorial Outline  Adding a search term  ‘Search’ Param added to controller method  LINQ query  Important details about when this actually gets executed  Goofy re-use of ‘id’ parameter for a nicer URL  Adding a form  Want to use GET, not POST (GET = retrieve, POST = change DB state)  Decorate form so that it’ll get, not post  Filtering by genre  Querying for the list of genres  Handling a GET’d search  Updating the view to support the above 12

Adding a parameter public ActionResult Index(string searchString) { var movies = from m in db.Movies select m; if (!String.IsNullOrEmpty(searchString)) { movies = movies.Where(s => s.Title.Contains(searchString)); } return View(movies); } 13 This is LINQ This defines, but does NOT execute the query This modifies the definition of the query LINQ actually maps to SQL (as opposed to doing a SELECT * and then filtering the results in C#

My opinion: using ‘id’ as the parameter  This seems goofy – it does produce a nice URL, but the controller code is kinda ugly (notice how they promptly renamed the parameter) 14

Adding a New Field started/introduction/adding-a-new-field 15

Outline 16

Adding Validation started/introduction/adding-validation 17

Examining the Details and Delete Methods started/introduction/examining-the-details-and-delete-methods 18

Topics For Later  Account Management:  dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/ dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/  Entity Framework:  Foreign keys  How does it handle objects with references to other objects?  JavaScript/jQuery integration? 19