How to host website in IIS with custom URL

Hello friends,

Recently i need to add website in IIS with custom URL to check third party account sign in. I want to share steps to create website in IIS with all of you to help someone who do it first time.

First you have to check IIS is installed in your machine or not. To confirm it go to Start -> Control Panel -> Programs -> Turn windows features on or off -> Internet Information Services -> Web Management Tools -> check IIS Management Console. Click OK.

To create website in IIS follow below steps.
-> Go to IIS Manager

IIS Manager

-> Right click on Sites. Select Add Web Sites.


-> Enter site name and select physical path. Also add Host name you want. Also set App pool.


-> Click on OK.

You have done all. Now, go to browser and type your URL. Enjoy!!!

Error 404.2 ISAPI and CGI list settings restrictions list settings on Web Server

Hello All,

Recently i have got an error 404 for ISAPI and CGI list settings restrictions list settings on Web Server.

To solve this problem we can set this in IIS.
-> Go to IIS manager click on Server Name.
-> Go in ISAPI and CGI Restrictions.
-> Select ASP.Net 4.0 (your .net version).
-> If it has “Not Allowed” then Right click and select “Allow”.

Now check your site the error will gone. To give more idea see below image.


Cannot add duplicate collection entry of type ‘add’ with unique key attribute ‘value’


Once I have transferred site from shared hosting to dedicated hosting and i got error “Cannot add duplicate collection entry of type add with unique key attribute value“.

see the below screenshot of error:

I have checked web.config file and IIS settings for this error.
I have seen below code in web.config file


This is for default document.

After that I have open IIS and check the site details, I have found below entries for the default documents:

So it occurs because of multiple entry of default page.

How can we solve it:To resolve this problem, first you must delete the duplicate entry that is defined at the highest level. The highest level may be the IIS server. After you delete the duplicate entry, the feature configuration page for the Web site or for the application should be displayed correctly.

How to redirect non www to www in

Hello All,

Today I am going to describe most common problem that we are encounter in these days.

Today we seen that most of the domains are work both ways i.e with and without “www” prefix.

Redirection of Non-WWW domain to WWW (301 Redirection – permanent) is very important for ranking on search engine like Google.

In SEO, The problem is that the Google search consider to be a different domain than so it makes the difference in search engine back links because you have made it with and without www prefix.

for SEO rankings; It is better to have every link use exactly the same form of your domain. for this purpose, it is common to redirect request from non-www to www.

Here I am going to describe how to Redirect non www to www in ASP.NET

we can do it in by many ways like using IIS, web.config, URL rewrite, Global.asax etc.
1. IIS : you can make a URL rewrite rule in IIS for the non www to www redirection
2. web.config : It is most common practice to do the redirection from non-www to www because we don’t have the IIS access on shared hosting environment.
see the below code for the redirection

    <clear />
    <rule name="WWW Rewrite" enabled="true">
      <match url="(.*)" />
          <add input="{HTTP_HOST}" negate="true"
            pattern="^www\.([.a-zA-Z0-9]+)$" />
        <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}"
          appendQueryString="true" redirectType="Permanent" />

3. URL rewrite : You can make your own HTTP module for the redirection
4. Global.asax : You can add your own code in Application_BeginRequest event
see below example

if (!HttpContext.Current.Request.Url.ToString().ToLower().Contains(""))
   string postedURL = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
   HttpContext.Current.Response.Status = "301 Moved Permanently";
   HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace(postedURL,""));

Hope this will help you.

Timeout settings in IIS and web.config

Hello all,

We all are facing timeout issue in iis or in our site. Sometimes client need more time to respond. So, we have to extend site timeout.

Timeout has Session Timeout and Idle Timeout.
Session timeout is set from web.config and from iis too.

To set from web.config write following code.



Default timeout is 20 minutes if you want more than that set in your session state. Timeout takes minutes. Here i have set 60 minutes.

Idle timeout only set from iis.
To set idle timeout go to iis
-> Application Pools
-> right click on your pools
-> select advance settings
-> go to process model
-> set value in Idle time-out.

Default value is 20 you can set it as you wish. I have added image for more idea.

301 permanent redirect in

Hi All,

In 301 redirects, The requested resource has been assigned a new permanent URI. it allows visitors and search engines to access a resource after it has been moved. If you have changed the domain or file names of resources, then you need to link it to new URLs for visitors and search engine spiders. The 301 permanent redirect is the most search engine-friendly method of redirection to the new URL.

You can implement it in different ways. some of them are as below.

A. In code file

protected void Page_Load(object sender, EventArgs e)
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location", "newurl.aspx");

1. In IIS, right click on the file or folder you wish to redirect.
2. Select Properties.
2. Select “A redirection to a URL”.
3. Enter the redirection page in “redirect to” textbox.
4. Check “The exact URL entered above”, and the “A permanent redirection for this resource”.
5. Click “Apply”.

C. In web.config file


If you are unable to set 301 redirects in your site and need any help then contact your hosting provider company.

File upload problem in IIS7

Hello Friends,

As you know that, If we want to upload file which is more than 50 MB then we are using following settings in web.config file for IIS6


Please note that maxRequestLength is in KB.

Once I have used above settings in my local server and it is working fine for file up to 2 GB but when i have tried to upload file in live server then it raise me error.

I have check my live server and found that my application are running on IIS7.

In IIS7, there are different handler settings than IIS6.
In IIS 7, the web application will reject any file that is larger than 30 MB. This is a default limitation of IIS7.

You can increase it by using below settings in web.config file.


Please note that maxAllowedContentLength is in byte.