Showing posts with label IIS. Show all posts
Showing posts with label IIS. Show all posts

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...

Friday, December 9, 2011

Hosting Web Page On IIS.

You can host your web page in your local system using Internet Information Services(IIS). How..??
Go to Internet Explorer type "http://localhost/", you will get one Image on your Browser. That is the default site hosted in your system on IIS. To see that file's physical location go to C:\inetpub\wwwroot, there you can see MyStart.htm file which will be running as localhost.


How can I host my site on IIS?
Its easy...Follow the steps below. This blog is with respect to Windows 7(IIS 7).


Step 1: 
Before you think about hosting, make sure that IIS has been installed in your system by typing 'inetmgr' in run command(Start->type run->Select Run). If it will opens IIS Manager window then you need not to worry, go to Step 3. If not, go to Step 2.


Step 2: 
Start->Control Panel->Programs->Turn windows features on or off (Under Programs and Features)->Select "Internet Information Services" check box in Windows Features window->Click OK.
Now goto Step 1.


Step 3:
Expand all the Tree structure in the left Connection pane of the IIS Window to see 'Sites' node as in the below figure.


Fig 1: IIS Manager



  • Right click on 'Sites' node->Add Web Site.. in IIS Manager.
  • Add Web Site Window will be opened as seen in Fig 2.
  • Enter Site Name(any name).
  • Leave Application pool as it is.
  • Click Browse Button to select the folder which contains your web page file and select it.
  • Leave Type and IP Address fields under Binding as it is. But Change Port to any other port number which is not being used.
  • Don't give Host Name. Click OK.

Fig 2: Add Web Site Window


  •  Now your website is ready to launch.
  • Right click on you site name under Sites in IIS Manager window(here it is TestSite)->Manage Website->Browse.
  • Internet Explorer will get opened with URL- http://localhost:<Port>/
  • Click on your web page file displayed on the browser or append that file name to URL.
  • Now your page will be displayed on the browser as shown below.

Fig 3: Web Page in Browser
Thats it...
Please put your Valuable comments if you get any issues..

Coming Next: Hosting .Net pages On IIS.