13

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/

Manish Tiwari
  • 1,806
  • 10
  • 42
  • 65

1 Answers1

17

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

Community
  • 1
  • 1
Jaqen H'ghar
  • 16,186
  • 8
  • 49
  • 52
  • I did according to this but when i run hostname on browser it runs IIS home page. – Manish Tiwari Jun 12 '16 at 18:29
  • @ManishTiwari What was the hostname you provided to the IIS in the textbox? What was the line you put in the hosts file? what address did you try to browse to? Did you try to right click your site on IIS and click Manage Website -> Browse to go to your website? – Jaqen H'ghar Jun 12 '16 at 18:33
  • 1
    Path `C:\inetpub\wwwroot\demo.com`, Hostname `demo.com`, In Host File `127.0.0.1 demo.com` And Browse in browser `demo.com` but it opens IIS landing page – Manish Tiwari Jun 12 '16 at 18:47
  • @ManishTiwari **1.** The path should be the directory of the website. Is your website directory really named `demo.com`? If not change it to the correct path. **2.** You might not have a default page in your website. After step 1 of comment, try to browse to a page in the website (ie if you have a test.html page in the directory - try browsing to http://demo.com/test.html) **3.** If it didnt work too, try to do [iisreset](https://msdn.microsoft.com/en-us/library/ms957500(v=cs.70).aspx) **4.** Good luck and please report back :) – Jaqen H'ghar Jun 12 '16 at 19:00
  • My application is in MVC 5 So how to set default Page ? – Manish Tiwari Jun 12 '16 at 19:06
  • @ManishTiwari There are many references regarding it. You can look [here for example](http://stackoverflow.com/questions/4208381/how-do-i-set-the-default-page-of-my-application-in-iis7). Also dont forget to check the path of your directory in IIS – Jaqen H'ghar Jun 12 '16 at 19:14
  • Thanks for the answer. This approach worked for me, but I did also have to restart my machine for it take effect. – Michael Hancock Jan 02 '20 at 13:27