Visual Studio 2012 IIS Express 8 Fresh Install - C

2019-02-11 22:37发布

问题:

On Visual Studio 2010 + IIS Express 7 I was able to use IIS Express as a server and browse sites.

I've since installed Visual Studio 2012 (on Windows 7 64-bit) with IIS Express 8, and I can't browse a single site on it. In addition, when I look at the log files (\Logs and \TraceLogFiles) I don't even see a single log entry for any of the 2012/IISExpress 8 apps, let alone an error to look into.

Looking at applicationhost.config, I do see the site I'm trying to run with the correct path, apppool and port.

But when attempting to run it, IIS Express 8 starts, I get an unusually long pause, and then I get a can't connect error in the browser. That is, in IE9 I get "Internet Explorer cannot display the webpage," in Chrome "Oops! Google Chrome could not connect to localhost:60046"

Has anyone else run into this? Is there something I need to do to complete the configuration of IIS Express 8 with VS2012?

UPDATE Mar 2 2013

This is still unresolved but here's a list of symptoms and partial solutions.

IIS Express completely non-functional I was unable to connect to IIS Express under any conditions, originally. It turned out I had 2 problems, one relating to DNS, and the other appearing to relate to a bug in Visual Studio 2012.

Issue 1: Windows DNS I had set my Windows wifi connection to use Google's DNS servers, rather than leaving it at Automatic. This worked fine with:

  • IIS
  • Cassini (Visual Studio internal webserver)
  • Nearly anything else

It did not work with:

  • IIS Express when attempting to connect to localhost - it fails to connect, even when running IIS Express from the command line, no Visual Studio involved.

The solution was to set my DNS settings back to Automatic (and switch my router to use Google DNS instead).

Issue 2: A bug in Visual Studio 2012 Microsoft is yet to acknowledge This got me to a point where IIS Express works fine from command-line, and the only remaining issue is connecting to it from Visual Studio 2012. Cassini and IIS (not Express) from VS2012 work fine, including localhost and the same projects that fail in IIS Express.

When I attempt to run against IIS Express however, the IIS Express tray icon appears, a minute goes by where Visual Studio appears to freeze, and then the tray icon vanishes and the same error message as shown in this question appears in Visual Studio:

Debugging MVC application in VS2012 attempts to start IIS Express twice

One peculiar thing is that if I right-click that tray icon and attempt to open a browser against it during the minute freeze-up, I get the web application - it runs for that one minute and works as intended. Then it dies when Visual Studio apparently kills it.

I however can't confirm that IIS Express is running twice as in w.brian's issue. That said, this may be the exact same Visual Studio 2012 bug just showing very slightly different symptoms.

Microsoft bugs and paywall I've reported the issue to Microsoft. They began diagnosing it with me, but then told me I'd need to pay $250 to continue - something I'm not prepared to do to help them fix their bugs.

There are several bug reports on this:

My original bug report: http://connect.microsoft.com/VisualStudio/feedback/details/766233/

A second one they had me open to navigate the bureaucracy: http://connect.microsoft.com/VisualStudio/feedback/details/779161/

w.brian's bug report: https://connect.microsoft.com/VisualStudio/feedback/details/778864/

But I suspect this is all the same bug that Microsoft is ignoring with a paywall between its customers and them, preventing them from actually gathering enough detail to recognize there's a bug here.

With Microsoft wasting enough of my time I've moved on to just using regular IIS as a workaround.

That's the absolute latest. Sorry everyone.

Update 8/2013: The machine that was experiencing this issue has since died (spilled something on it), and my new machine doesn't have this issue. I've suggested to Microsoft they reach out to others here with this issue. It may make sense to comment here if you're still experiencing the problem so they know how to contact you. And remember you can edit StackOverflow questions, so you can always just update this question yourself with more diagnosis information.

回答1:

I tracked down the problem on my machine.

When I checked my C:\Windows\system32\drivers\etc\hosts file, I did not have

 127.0.0.1   localhost

in the file. I remember changing it "temporarily" to troubleshoot a problem. Adding back in the missing record fixed my problem.

You can test what IP your machine thinks localhost is by simply ping localhost and making sure that 127.0.0.1 is pinged and not some other IP.



回答2:

Did you check if the http bindings registration happened for your site? (running "netsh http show servicestate" command from command prompt would show all the registered bindings and check if your site binding "localhost:60046" exists or not)

if your site binding does not exists, try following to check why bindings registration is failing.

  1. Open command prompt
  2. Goto IIS Express installation folder (%programfiles%\iis express)
  3. Start your site from command line by using following command line iisexpress.exe /site:"your-site-name" /trace:d
  4. Step 3 would show error message if the bindings registration fails


回答3:

I had a similar issue running my asp.net MVC4 project on localhost under IIS express 8.0 so I ended up uninstalling IIS 8.0 and installing IIS express 7.5 and straight away the problem was fixed:

  • Uninstall IIS express 8.0
  • Delete the My Documents\IISExpress folder
  • Install IIS express 7.5 (Link to IIS Express 7.5 download)

IIS Express 8.0 seems to be installed with VS 2012 so if you had a new install or possibly a service pack update this might have upgraded your previous IIS express version.



回答4:

I know this question was answered by the original poster, but for those who get here through google, here is a possible solution to your problems: HTTPS stopped working with IIS express



回答5:

If anyone else has this issue - make sure any website bindings in applicationhost.config refer to valid addresses.

I had this message when applicationhost.config was binding to a specific IP address, but that IP wasn’t valid for the host at that time (I had an internal network IP assigned via a DHCP reservation, but I was on a different network).



回答6:

I resolved my issues with IIS by installing WebMatrix (download). I ran WebMatrix, opened a site in WebMatrix and IIS fired up just fine. Closed WebMatrix and ran an ASP.NET MVC site in VS and it worked.