ASP.NET Essentials State management, authentication, and Web Services Daniele Pagano Arizona State University.

Slides:



Advertisements
Similar presentations
Forms Authentication, Users, Roles, Membership Ventsislav Popov Crossroad Ltd.
Advertisements

1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
Michael Donovan, River Campus Libraries – 12/03 DocuShare Overview and Training.
Authenticating Users in an ASP.NET Application. Web Site Administration Tool From VS 2008, click Website/ ASP.Net Configuration to open Web Site Administration.
Building ASP.NET Applications 2 Lecture 3,4 T. Ahlam Algharasi 4 th Level.
Membership, Role Manager and Profile Membership, Role Manager and Profile Matt Gibbs ASP.NET Development Manager.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Role based Security in.NET By By Aasia Riasat Aasia RiasatCS-795.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 21: Publishing Your Pages on the Web.
1 Chapter Overview Creating User and Computer Objects Maintaining User Accounts Creating User Profiles.
Sharepoint Portal Server Basics. Introduction Sharepoint server belongs to Microsoft family of servers Integrated suite of server capabilities Hosted.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
Internet Information Server 6.0. Overview  What’s New in IIS 6.0?  Built-in Accounts and IIS 6.0  IIS Pass-Through Authentication  Securing Web Traffic.
CONFIGURING WINDOWS SERVER MIS 424 Professor Sandvig.
1 ASP.NET SECURITY Presenter: Van Nguyen. 2 Introduction Security is an integral part of any Web-based application. Understanding ASP.NET security will.
This presentation will guide you though the initial stages of installation, through to producing your first report Click your mouse to advance the presentation.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Scottish Legal Aid Board Content Management using OpenCms Martin Spinks CTO Navyblue Tuesday, March 16, 2010.
Deployment of web Site. Preparing the web site for deployment you now have two versions of web site 1 -one running in the production environment 2-one.
Session 11: Security with ASP.NET
Forms Authentication, Users, Roles, Membership Svetlin Nakov Telerik Corporation
JavaScript, Fourth Edition
WaveMaker Visual AJAX Studio 4.0 Training Authentication.
Copyright 2000 eMation SECURITY - Controlling Data Access with
1.NET Web Forms Security Issues © 2002 by Jerry Post.
Session 10: Managing State. Overview State Management Types of State Management Server-Side State Management Client-Side State Management The Global.asax.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Managing State.
State Management. What is State management Why State management ViewState QueryString Cookies.
E-Commerce: Introduction to Web Development 1 Dr. Lawrence West, Management Dept., University of Central Florida Topics What is a Web.
Course ILT Internet/intranet support Unit objectives Use the Internet Information Services snap-in to manage IIS, Web sites, virtual directories, and WebDAV.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Securing a Microsoft ASP.NET Web Application.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
1 Web services and security ---discuss different ways to enforce security Presenter: Han, Xue.
Chapter 8 Cookies And Security JavaScript, Third Edition.
.Net and Web Services Security CS795. Web Services A web application Does not have a user interface (as a traditional web application); instead, it exposes.
Module 5 Configuring Authentication. Module Overview Lesson 1: Understanding Classic SharePoint Authentication Providers Lesson 2: Understanding Federated.
1 CS 3870/CS 5870: Note 11 Authentication and Authorization Membership Provider.
Dr. Mustafa Cem Kasapbaşı Security in ASP.NET. Determining Security Requirements Restricted File Types.
Introduction to ASP.NET T.Ahlam Algharasi. The Visual Studio IDE Start page 2.
Effective Security in ASP.Net Applications Jatin Sharma: Summer 2005.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
ASP.NET State Management. Slide 2 Lecture Overview Client state management options Cookies Server state management options Application state Session state.
MCTS Guide to Microsoft Windows Server 2008 Applications Infrastructure Configuration (Exam # ) Chapter Five Windows Server 2008 Remote Desktop Services,
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Module 11: Securing a Microsoft ASP.NET Web Application.
Slide 1 ASP Authentication There are basically three authentication modes Windows Passport Forms There are others through WCF You choose an authentication.
Module 7: Creating a Microsoft ASP.NET Web Application.
What is Web Site Administration Tool ? WAT Allow you to Configure Web Site With Simple Interface –Manage Users –Manage Roles –Manage Access Rules.
MEMBERSHIP AND IDENTITY Active server pages (ASP.NET) 1 Chapter-4.
GUDURU PRAVEEN REDDY.NET IMPERSONATION. Contents Introduction Impersonation Enabled Impersonation Disabled Impersonation Class Libraries Impersonation.
Web Access. Overview  Purpose  Prerequisites  Install Components  Enable Virtual Directories  IIS Configuration & Security  Troubleshooting.
Module 4: Creating a Web Application with Web Forms
Security E-Learning Chapter 08. Security Control access to your web site –3 Techinques for Identifying users Giving users access to your site Securing.
Configuring and Deploying Web Applications Lesson 7.
(ITI310) By Eng. BASSEM ALSAID SESSIONS 10: Internet Information Services (IIS)
Working with ASP.NET Controls What is ASP.NET Using server controls in your pages Allowing users to create their own accounts Creating a login page Letting.
Business Objects XIr2 Windows NT Authentication Single Sign-on 18 August 2006.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
19 Copyright © 2008, Oracle. All rights reserved. Security.
Security In your webSite.
Unit 7 Learning Objectives
Security Basics and ASP.NET Support
Jim Fawcett CSE686 – Internet Programming Summer 2005
Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek
Created by : Asst. Prof. Ashish Shah
Module 10: Creating a Web Application with Web Forms
Presentation transcript:

ASP.NET Essentials State management, authentication, and Web Services Daniele Pagano Arizona State University

Overview State Management Application State Application State Session State Session State Storage and Scalability Storage and Scalability Authentication and Authorization Security overview Security overview Windows-based and form-base authentication Windows-based and form-base authentication NTFS and URL-based authorization NTFS and URL-based authorization XML Web Services What are Web Services? What are Web Services? Creating Web Services Creating Web Services Using Web Services Using Web Services

State Management In most cases you will need to keep data stored across requests and track users during their visit. Application state will preserve data across users in a global area. Session state will recognize one user and allocate some data for each. HTTP is stateless, so other systems must be used, such as cookies and URL id’s. ASP.NET abstracts these from you. You just need to worry about what to store.

The Application State Any data you share among multiple users. You can easily add and remove items from your application state. Since this is a shared resource, you should lock it every time you write to it, then unlock it. Hints: Lock the application state for as little time as possible. Lock the application state for as little time as possible. Put unlock in a finally block so it’s always executed. Put unlock in a finally block so it’s always executed. Application state stores items as Object type, don’t forget to cast them back to your specific type. Application state stores items as Object type, don’t forget to cast them back to your specific type. Store data you don’t need all the time, or that you need to survive a server crash or restart, in a file or database. Store data you don’t need all the time, or that you need to survive a server crash or restart, in a file or database.

Application State code snippet // Code// Shows: if((int)Application["UserCount"] > 1)// cast your retrieved values // In the right context, toString() is called, no need to cast this.lastserve.Text = "Last access: " + Application["LastAccess"]; try{ Application.Lock();// Lock before use Application["LastAccess"] = DateTime.Now; } finally// This is ALWAYS run { Application.UnLock();// Unlock after use }

The Session State Maintains data for individual users. Uses cookies normally, but cookie-less option also available. Works like Application object, but no need to lock/unlock as it’s not shared. Use syntax Session[“MyVar”] as before. Hints: It’s enabled by default, disable it in every page in which you don’t use it (via Properties pane) to save resources. It’s enabled by default, disable it in every page in which you don’t use it (via Properties pane) to save resources. Remember that each piece of data you store in memory is allocated for each user. Remember that each piece of data you store in memory is allocated for each user. Understand and use the different methods for state storage (coming up next). Understand and use the different methods for state storage (coming up next).

Session State Storage options Choose via web.config file by updating sessionState mode property: In-Process (InProc) In-Process (InProc) Default. Session is stored in the process memory for each user. Out-of-process (StateServer) Out-of-process (StateServer) A separate server will handle storing the session data. You’ll need to start the ASP.NET State Service and update stateConnectionString. SQL Server (SQLServer) SQL Server (SQLServer) An SQL database (local or on a different server) will store the session data. You’ll need to run InstallSqlState.sql (in the.NET framework directory) against your main db and update sqlConnectionString. Cookieless Set/unset this sessionState property to use sessions without cookies.

Scalability Issues Several state management issues can compromise your speed and scalability: Misuse of Application.Lock(): make sure you use it as little as possible and always unlock. Misuse of Application.Lock(): make sure you use it as little as possible and always unlock. Use of session state: don’t leave session state enabled unless you use it. You can disable it in one page even if it’s used in others. Use of session state: don’t leave session state enabled unless you use it. You can disable it in one page even if it’s used in others. Abuse state storage: this easily eats up your memory if you store too much data, especially for session state, as it’s multiplied for each user. Abuse state storage: this easily eats up your memory if you store too much data, especially for session state, as it’s multiplied for each user. Use of non-thread-safe objects: make sure whatever you store in application or session is thread-safe or your whole application will be blocked. Use of non-thread-safe objects: make sure whatever you store in application or session is thread-safe or your whole application will be blocked. Multi-server: application and session data stored in- process will not carry over to Web farms. Use a state server or a central database instead. Multi-server: application and session data stored in- process will not carry over to Web farms. Use a state server or a central database instead.

ASP.NET Security issues Security will be covered next time, these are the main issues to keep in mind and that will be covered. Make sure you are aware of these techniques: Configure your file system for safety Configure your file system for safety Disable unnecessary services Disable unnecessary services Create security policies and templates Create security policies and templates When, where, and how to configure passwords When, where, and how to configure passwords Remove sample web applications Remove sample web applications Use validation extensively Use validation extensively Check for and install patches regularly Check for and install patches regularly Configure logging Configure logging Configure SSL Configure SSL And more… And more…

Windows-based authentication Relies on IIS Comes in basic (least secure), digest (more secure, uses domain servers), and NTLM (most secure, IE only). Enable and configure via IIS: Choose the resource to protect Choose the resource to protect Click on Properties Click on Properties Select Directory security or File security tab Select Directory security or File security tab Click Edit… button on authentication control Click Edit… button on authentication control Uncheck anonymous access and check desired authentication method(s). Uncheck anonymous access and check desired authentication method(s).

Forms-based authentication It’s mostly automated in ASP.NET Create a login page that obtains a username and password from the user. Call FormsAuthentication.Authenticate with username and password. Returns true or false. Configure web.config to use forms authentication. Create user credentials with hashed passwords.

Web.Config snippet for Forms authentication You’ll need to modify web.config so that it know what’s the login page and who are the users. You’ll need to modify web.config so that it know what’s the login page and who are the users. </forms></authentication><authorization> </authorization> Make sure you set the right password format and generate the hash with some program (available on the web too).

Authentication code snippet Since ? (anonymous) users are denied, the page specified in the web.config (like login.aspx) will be displayed. There you’ll collect user information and login. To login, use the automatic authentication and then redirect the user to the page the were denied access to. Using System.Web.Security.... private void Login_Click(object sender, System.EventArgs e) { if(FormsAuthentication.Authenticate(user.Text, pass.Text)) { FormsAuthentication.RedirectFromLoginPage(user.Text, false); }} To logout use FormsAuthentication.SignOut();

Authorization If you’re using Windows authentication, just set up file permission for the user that has logged in. Add to your web.config. You can also use the authorization section of the web.config to allow or deny users and roles from a web page. This applies to the root and all sub- directories without conflicting web.config settings.

Authorizing a specific URL To authorize certain users to specific URL’s, you can add this to your web.config outside the main system.web element: <system.web><authorization> …allows and denies… </authorization></system.web></location>

XML Web Services Web Services allow you to invoke any code across the web. They make great middle-tier material. They use XML and SOAP to work across platforms and transmitting text across firewalls (using port 80). Can be implemented in any language, but.NET makes it very easy. Can be searched, located and linked to using UDDI servers.

Creating a Web Service In Visual Studio.NET, create a new Web Service project in your favorite language. Write your code normally (as in a library) in.asmx file Add [WebMethod] before any method you’d like to publish. Build your solution. That’s it!

Using a Web Service In Visual Studio.NET Solution Explorer, right-click on References, and select Add Web Reference. Paste the URL of the.asmx file or locate one with the options provided. Click Add Reference. Now the classed and methods exported by the web service are available to your transparently, enjoy!

What we have learned How to create more customized and dynamic web applications using Application and Session management. Some ways to make sure our web applications are scalable. What are the main security issues to keep in mind. Simple ways to authenticate and authorize users on our website. How to use web services.

Q&A