Nov 1, 2011

How to create the virtual directory on the web server

1. To start IIS Manager, select Settings -> Control Panel -> Administrative Tools Internet Services Manager from the Start menu.
2. The next step would be to create a virtual directory for an existing physical directory. For this please expand the Web Sites item in the IIS tree, right-click the Default WebSite item and choose New -> Virtual Directory from the menu (see Figure 2).

Figure 2. Creating a Virtual Directory
3. The first step in the wizard responsible with the virtual directory creation is to choose an alias (see Figure 3). The alias is the name a user will use in his URL to access the files in this virtual directory. 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.

Figure 3. Choosing an alias.
4. Click Next
5. The next step in this wizard is to provide an existing physical directory to which the virtual directory will point to (see Figure 4). So, this physical directory will be exposed as a virtual directory through its alias. For example, c:\Webs\WebApplication1 is the physical directory that is used by this virtual directory with the MyApplication alias.

Figure 4. Choosing a physical directory

6. The final step in this wizard is to choose your permissions for the virtual directory (see Figure 5). Usually, to host an ASP.NET application, read and execute permissions are enough (the first two check boxes). Of course, in order to fulfill your needs you can choose other permissions too.

Figure 5.Setting permissions
7. Click Next and then Finish to create the virtual directory.
When you finish these steps, you'll see your new virtual directory appear in the list in IIS Manager.

Copy the entire site (including subdirectories) to the virtual directory

The deployment of the ASP.NET application on the production machine can be done in many ways depending on the Internet hosting services.
You can use FTP to deploy the application, or if the development computer and the web server are on the same internal network, you can use Windows explorer.
Please also consider the tools that Visual Studio includes to make deployment easier.

Configuring an Existing Virtual Directory

IIS provides plenty of features you can use to configure the virtual directory that you have just created. In order to do that, simply right click the virtual directory in the list, and choose Properties item from the context menu. The Properties window will appear, with its information divided into several tabs. The following topic briefly explains the most important tabs you’ll want to configure for ASP.NET applications.
Directory tab
The Virtual Directory tab provides basic information about your virtual directory. At the top of the tab you can find information about the physical path for this virtual directory. So, the local path of the physical directory can be read-only if you are looking at a subdirectory inside a virtual directory, or you can set the local path to point to a different physical directory by clicking Browse button. (see Figure 6)

Figure 6. Directory tab
Authentication and access control in Directory Security tab
Here you can specify how IIS authentication is made. I will also explain how impersonation is made.
So, here you can see which is the account IIS uses for anonymous access and also which are the authenticated access modes.
When IIS is configured for anonymous access, ASP.NET makes requests for system resources using IUSR_MachineName account (in out case, IUSR_SQLServer). When a user authenticates directly to IIS using a Windows logon, ASP.NET impersonates that user account. (see Figure 7)

Figure 7. Authentication methods
ASP.NET tab
As the name suggests, the ASP.NET tab provides useful features only for ASP.NET applications:
- It provides information about the current version of ASP.NET you’re using for this application (you can host on the same machine applications that require different version of ASP.NET)
- You to choose any version of ASP.NET that’s installed on the computer just by selecting it from a drop-down list.
- In provides information about the physical path and about the web.config file.
- It provides you a more user friendly way to configure the setting in web.config file. In order to do this, just press Edit Configuration button (see Figure 8)

Figure 8. ASP.NET tab

Windows permissions

Keep in mind the ASP.NET engine runs under ASPNET account in Windows XP or under Network Service account under Windows 2003 Server. In order you to access an ASP.NET web site, these accounts must have windows permission on the virtual directory. Right click on the virtual directory you have just created and choose Permissions option like below. Now, give the appropriate windows permissions to ASPNET or Network Service. (see Figure 9)

Figure 9. Give windows permissions

Test the web site

Let's suppose that your web site has a Default.aspx web page. In order to test the web site, open your favorite browser and try to access the bellow link: http://localhost/MyApplication/Default.aspx
If the Default.aspx web page appears correctly that means that everything went OK.
If you receive the below result, that mean that ASPNET or Network Service account doesn't have appropriate windows permissions on that virtual directory.

Figure 10. Server application Unavailable
If you receive the below result, that means that IUSR_MachineName account or the windows account under which you are authenticated doesn't have appropriate windows rights on the virtual directory. This depends on the IIS authentication mode you have chosen to use.

Figure 11. Access denied by ACL
Phải cài IIS trước khi cài NetFramework 2.0, nếu đã lỡ cài NetFramework 2.0 trước thì phải Repair lại nó là OK. (Vì lỗi này chỉ xảy ra với ASP.NET 2.0) 

Open visual studio command prompt and type this command

aspnet_regiis -ga \username
username is usually aspnet

if this doesn't work than use this command
aspnet_regiis -i

alternatively you can copy and paste this command into windows command prompt

%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

this will fix your problem

0 comments:

Post a Comment

Nam Le © 2014 - Designed by Templateism.com, Distributed By Templatelib