Chapter 26


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Chapter 26

  1. 1. • ASP.NET Applications and the Web Server• How Web Servers Work• The Virtual Directory• Web Application URLs• Internet Information Services (IIS)• Managing Websites with IIS Manager• Understanding Application Pools• The ASP.NET Account• Configuring a Website• Deploying a Simple Site
  2. 2. • A specialized piece of software that accepts requests over Hypertext Transport Protocol (HTTP) and serves content.• When you’re running your web application in Visual Studio, you use the test web server that’s built in.• When you deploy your website to a broader audience, you need a real web server, such as IIS.• Web servers run special software to support mail exchange, FTP and HTTP access, and everything• else clients need in order to access web content.
  3. 3. • The easiest job a web server has is to provide ordinary HTML pages. When you request such a file, the web server simply reads it off the hard drive (or retrieves it from an in-memory cache) and sends the complete document to the browser.• When you request the ASP.NET page, the web server sends the request over to the ASP.NET engine. The ASP.NET engine loads the requested page, runs the code it contains, and then creates the final HTML document, which it passes back to IIS. IIS then sends the HTML document to the client.
  4. 4. When you deploy your web application to a web server,it’s exposed through something called a virtual directory.A virtual directory is simply the public face of your websitedirectory.For example, your website might exist in a directory on theserver named c:MySite. To allow remote users to accessthis website through their browsers, you could expose itas a virtual directory say MySite.When the user requests a page in a virtual directory (say,http://WebServer/MySite/Checkout.aspx), the web serverlooks for the corresponding file in the correspondingphysical directory (c:MySiteCheckout.aspx).
  5. 5. You can use ASP.NET applications in a variety of differentenvironments, including local area networks (LANs) andover the Internet.On an IP network, each computer is given a unique numbercalled an IP address. IP addresses aren’t easy toremember web servers on the Internet usually registerunique domain names such as an internal network computers can access yourwebsite using either the IP address of your machine thenetwork computer name.
  6. 6. http://localhost/MyWebApphttp://MyWebServer/MyWebApp
  7. 7. Instead of placing web application files on a single webserver, you place a copy on several separate webservers. When a request is received for your website, it’s directedto one of these web servers (based on which one has thelightest load).if you decide to update your application, you need tomake sure you update each web server in the web farmwith the same version to prevent discrepancies.
  8. 8. IIS exists in several different versions. The version of IISyou use depends on the operating system you’re using:• Windows Server 2003 uses IIS 6, which isn’t covered in this book.• Windows Vista and Windows Server 2008 use IIS 7.• Windows 7 and Windows Server 2008 R2 use IIS 7.5Windows Vista and Windows 7, are fine for developmenttesting, but they implement a connection limit to 10 users.
  9. 9. When IIS is installed, it automatically creates a directorynamed c:inetpubwwwroot. Any files in this directory willappear as though they’re in the root of your web server.If you add the file TestFile.html to this directory, you canrequest it in a browser through the URLhttp://localhost/TestFile.html.You can even create subdirectoriesc:inetpubwwwroot MySiteMyFile.htmlcan be accessed as :http://localhost/MySite/MyFile.html.
  10. 10. The easiest and most flexible way to create a virtualdirectory is to use the IIS Manager utility1. To create a new virtual directory for an existing physical directory, expand the node for the current computer, and expand the Sites node underneath.2. Right-click the Default Web Site item, and choose Add Application.3. Supply the alias. For example, if your alias is MyApp and your computer is MyServer, you can request pages using URLs such as http://MyServer/MyApp/MyPage.aspx.4. Next, you need to choose the physical path5. Next, you need to specify the application pool.
  11. 11. The web application pool sets a small group of low-levelsettings that apply only to ASP.NET applications,Such as the maximum number of requests to put on holdbefore sending a “Service Unavailable” response to newclients (by default, it’s 1000) etc.Application pools include two settings that are uniquelyimportant and may require your customization:• The version of ASP.NET that IIS runs to process the requests in your website• The Windows account that IIS uses to run your website
  12. 12. When the web server runs your web application, it performsall its work under a specific Windows user account that has acarefully limited set of privileges. The actual account that’sused depends on the web server you’re using:• If you’re using the integrated test server in Visual Studio, the server runs under your account.• If you’re using IIS 7, it’s the network service account. This is a special account that Windows creates when you first install it.• If you’re using IIS 7.5, it’s an account that’s based on the application pool. For example, an application pool named ASP.NET v4.0 will use an account named IIS AppPoolASP.NET v4.0, which IIS generates automatically.
  13. 13. The website configuration settings are split into threebroad groups, which are arranged alphabetically:ASP.NET, IIS, and Management.
  14. 14. IIS supports several different protocols that it can usewhen authenticating a user with Windows authentication
  15. 15. Before you can use any type of Windows authentication, you need to install theappropriate support for IIS. To add support, open the Control Panel, choosePrograms and Features, and then click the link “Turn Windows features on oroff.” Head to the Internet Information Services ➤ World Wide Web Services ➤Security group
  16. 16. Once you have the authentication features you need installed, you simply needto select your website in IIS manager and double-click the Authentication icon (inthe IIS group). Now you’ll see whatever authentication options you’ve installed.
  17. 17. All you need to do is follow these two simple steps:1. Create the virtual directory on the web server.2. Copy the entire site (including subdirectories) tothe virtual directory.This is often called zero-touch deployment,because you don’t need to manually configure webserver resources However, some applications aremore difficult to set up on a web server.
  18. 18. Here are some common factors that will require additionalconfiguration steps:Databases: If your web application uses a database, you’ll needto transfer the database to the web server. You can do this bygenerating a SQL script that will automatically create thedatabase and load it with data.Windows account permissions: Usually, a web server will run webpage code under a restricted account. This account might not beallowed to perform the tasks you rely on, such as writing to files orthe Windows event log, or connecting to a database. In this case,an administrator needs to specifically grant the permissions youneed to the account that runs the ASP.NET engine for yourwebsite.IIS security settings: If your website uses SSL encryption orWindows authentication the virtual directory settings will need tobe tweaked. This also requires the help ofan administrator.
  19. 19. A command-line tool named aspnet_compiler.exe,which is stored in the familiar directory.c:WindowsMicrosoft.NETFramework64[Version]You use this compiler on your developmentmachine before you deploy the application.aspnet_compiler -m metabasePath targetDirectory
  20. 20. Visual Studio includes features that integrate with IISand allow you to create virtual directories withoutleaving the comfort of your design-time environment.Visual Studio has several deployment-related features:• You can use the Copy Web Site feature to transfer an existing website to a virtual directory.• You can use the Publish Web Site feature to compile your website and transfer it to another location.
  21. 21. Select Website ➤ Copy Web Site from the menu
  22. 22. Select Build ➤ Publish Web Site from the menu