deployment of web site. preparing the web site for deployment you now have two versions of web site...

32
Deployment of web Site

Upload: elfrieda-joseph

Post on 26-Dec-2015

218 views

Category:

Documents


2 download

TRANSCRIPT

Deployment of web Site

Preparing the web site for deployment• you now have two versions of web site1 -one running in the production environment 2-one you use for development.

This makes it difficult to keep things synchronized

Avoiding hardcoded setting

• myMessage.From = New MailAddress(“[email protected]“, “Sender Name“);• myMessage.To.Add(New MailAddress(“[email protected]“, “Receiver Name“));

• Hardcoding settings in this manner makes it difficult to give them different values in different environments.

• Every time you want to roll out your site to production, you need to make sure you’re not accidentally overwriting settings you changed for the production environment.

Solution for this kind of problems

• the web.config file,• expression syntax, and the webConfigurationManager class

you use to read from web.config.

Web.config file• We have used web.config file to store

information about connection string,roles,profiles,membership.

• <appSettings> element that enables you to store data in a key/value pair using <add> elements.

<appSettings>• The <appSettings> element enables you to store simple

information, such as an e mail address, and retrieve that ‑value by its key. For example, to store an e mail address, ‑you can add the following to the web.config file:

• <appSettings><add key=“FromAddress” value=”[email protected]” /></appSettings>• The <appSettings> element is placed outside the <system.web> element in the

web.config file, yet still within the parent <configuration> element.

• Obviously, you need a way to access the data in <appSettings> at runtime. You can do this in a couple of ways, including expression syntax and the WebConfigurationManager class

Expression setting• Expression syntax enables you to bind control

properties to resources, such as those found in the <appSettings> element in web.config, connection strings, localization resource files and various routing settings used in URL rewrite scenarios. To display data from the <appSettings> element,

you use the following syntax where AppSettingKeyName refers to a key you define in web.config:

<%$ AppSettings:AppSettingKeyName %>

webConfiguration Manager classThe WebConfigurationManager class from the

System.Web.Configuration namespace provides access to data that is stored in configuration files. It has special support for the appSettings and connectionStrings elements of the web.config file, enabling you to retrieve data from those sections with a single line of code.

using System.Web.Configuration;...string fromAddress= WebConfigurationManager.AppSettings.Get(“FromAddress”);<add key=”SendMailOnError” value=”true” />

bool sendMail =Convert.ToBoolean(WebConfigurationManager.AppSettings.Get(“SendM

ailOnError”));

Copying your web siteDuring development of your site you use the

built-in web server that ships with Visual WebDeveloper. Although this server is great for local

development, you can’t use it in a production environment,because it only listens to requests coming from localhost. To put your site in production,you need to deploy it to a machine that runs IIS (Internet Information Services), Microsoft’s professional web server.

Deployment options

Copying web siteThe Copy Web Site option simply creates a copy of all files that

make up your site. It can create a copyof the site at different locations, including the local file system, an

FTP server, and an IIS server.To copy the files to the local system. This is a great way to create a

copy that is detached from the development environment that can be run on your local machine.

when you’re creating the copy over a slow FTP connection, you’ll be glad this tool only uploads new and changed files,and leaves unmodified files untouched. You can, of

course copy the same set of files to another machine using an FTP program, a USB stick, and so on. The detached local copy enables you to make modifications to a few files first (like web.config) and then upload everything to your host.

Publishing web siteit allows you to precompile the application, which means all

the code in the Code Behind of your ASPX pages, controls, code files in App_Code, and so on are compiled into .NET assemblies; files with a .dll extension in the bin folder of your site. The main benefits of precompiling are source protection (others with access to the server can’t look into your source) and an increased performance the very first time a page is requested. Pages that are not precompiled are compiled on the fly when they are requested the first time, which takes a little bit of time. Remember that regular visitors to your site will never be able to see the source of your application. All they’ll be able to see is the final HTML that gets sent to the browser.

Running your site under IIS

• 1. Install and configure IIS.

• 2. Install and configure the .NET Framework 4

• 3. Configure security settings.

• type on start appwiz.cpl • After the installation of iis ,you have to make

sure that Microsoft .NET FRAMEWORK VERSION 4 IS INSTALLED.

Inastalling and configuring ASP.NET• IF You have iis and microsoft .NET frramework 4

installed ,you have to tell the iis that you have framework 4 on your machine.(it is only required if you install IIS later).

• Each new IIS installation has a Default Web Site, the site that listens to http://localhost by default.

• It means that a URL like http://localhost/Login.aspxis mapped to the physical file at C:\BegASPNET\Release\

Login.aspx.

Application pool• You assign a web site “an application pool”an IIS mechanism to isolate and configure one or

more IIS web sites in one fell swoop. Two web sites running in different application pools do not affect each other in case of a problem such as a crash.

Understanding Security in IISIn order to use resources in your site, such as ASPX files,

Code Behind files, the database in the App_Data folder, and the images in your site, your web server needs permissions from Windows to access those resources. This means that you need to configure Windows and grant access to those resources to the account that the web server uses.

there are only two scenarios to consider: using the built-in web server or using IIS as your web server.

For IISwhere IIS is used, things are quite different. By default, an

ASP.NET application under IIS runs with a special account created when you installed IIS. This account is called Network Service on Windows Vista, and the original release of Windows Server 2008 and it is called ApplicationPoolIdentity on Windows 7 and Windows Server 2008 R2.

NTFS setting for websiteyou’ll need to make changes to the Windows file system,so the web server is allowed to access your resources. This is

only necessary when your hard drive is formatted using NTFS and not with FAT or FAT32, the older Microsoft file systems

To successfully configure your NTFS file system for the web site, you need to grant the following permissions to the web server accounts

Permission to the web server account

Moving Data to Remote server• Obtain and install SQL server management

studio express