Tuesday, December 13, 2011

Hosting .Net pages On IIS.

In previous blog we learnt how to host simple HTML page on IIS 7. This is the continuation of the last post, so you should be able to host simple html page before to play with aspx pages.
Hosting Simple HTML pagehttp://charanmandya.blogspot.com/2011/12/hosting-web-page-on-iis.html 

Now we are going to host .Net applications like aspx pages as in separate blog as it is bit complicated than html.

Before going to host aspx page, make sure that Application Development Feature for ASP has turned ON. For that follow the steps below:
Start àControl Panel à Programs à Click 'Turn windows feature on or off ' à  Expand 'Internet Information Services' à Expand 'World Wide Web Services' à Expand 'Application Development Features' à Select all the Check boxes à Click OK
After installation, you will see the window asking to restart system. Allow to do restart. 

  • Create your .Net Application with .aspx pages in Visual Studio and make sure that its error free.
  • Create new folder(For the better case place it in C:\inetpub\wwwroot\). And copy .aspx and .cs pages in to that folder.
  • Host new Web Site as we done in previous post with this newly created folder as Physical path.
  • Right click on your site,under 'Sites' node àManage Web Site à Browse
  •  You will see the aspx Webpage as in Fig: 1 or some Errors..

Fig 1: Browser window of hosted aspx page.

What kind of Errors you will get?

HTTP Error 401.3 - Unauthorized

You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.
Solution: 
Copy your folder and paste inside C:\inetpub\wwwroot\.
Then change Physical path of the Site to 
C:\inetpub\wwwroot\<Your_Folder_Name>


HTTP Error 403.14 - Forbidden 
The Web server is configured to not list the contents of this directory.
Solution: 
Select your site under 'Sites' node à Double click on 'Directory Browsing' in Features View à On the Directory Browsing page, in the Actions pane, click Enable.
This process creates 'web.config' file inside your directory which contains following code:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="true" />
    </system.webServer>
</configuration>


Server Error in '/' Application.
Parser Error Message: Could not load type 'ASP.Default'.
Source Error:


Line 1:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ASP.Default" %>

Solution: 
Replace 'CodeBehind' property in Page tag with 'CodeFile' like code below:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="ASP.Default" %>


Put your valuable Comments, and Errors if you will get any...

No comments:

Post a Comment