How to configure IIS 7 for localhost website?

2020-05-19 07:56发布

I am new in Asp.Net

I have enabled features of IIS 7 on my windows system and able to see IIS manager.

I created an application but build/run application through visual studio it goes to browser and run the application with different port number. When i stop build/run application through visual studio and again i refresh browser application could not run.

I want to run application without visual studio. How to do this.

It gives this : http://localhost:9864/

1条回答
爷的心禁止访问
2楼-- · 2020-05-19 08:28

To configure IIS with a new website follow these instructions:

  1. Open IIS manager, right click Sites (At the right menu) and click Add Website

  1. Give the site a Site Name, The physical path on your machine, and a Host Name

    There are some conventions as for what website physical path to choose you can read about it in this SO question

  1. In Windows Explorer go to C:\Windows\System32\drivers\etc and Edit the hosts file

    Add this line at the end of the file:

    127.0.0.1 your-chosen-host-name-from-iis-ie-localhost.testsite.com

    And save the file

Thats about it. You can open your browser and browse the Host Name you chosen for your website or in IIS right click your site and click Manage Website - Browse

Important note

If you wish to use the same address as your VS uses (http://localhost:9864/) then on step 2 leave the Host Name textbox blank and instead change the Port textbox to your desired port (9864). In this case you can also ignore step 3.

As a site note:

If you installed IIS on your machine after the VS installation you might get some conflicts. You might be able by this stage to browse to static content as html but not .NET resources like aspx files. If by browsing to .NET files you get a message saying The page you are requesting cannot be served because of the extension configuration you can solve it with this SO question

查看更多
登录 后发表回答