Intro:
When i run an asp.net web app that is freshly created, it runs just fine. However, it runs only for the 1st time. Subsequent runs will fail with this message:
The only way to make it run again is to restart VS2017. Not even restarting IIS/IISExpress will make it work again.
At this point my instincts tell me there is something stupid/silly going on. What on earth is going on here?
Here is my configuration:
- I am using Visual Studio 2017 Version 15.8.4
- .Net Framework Version 4.7.03056
- Project: Asp.net Web Application (.Net Framework) ==> MVC
- This is being run under - IIS Express (Internet Explorer)
Here are more details about the error im seeing:
The error page simply says "Can't reach this page".
When i click on the "More information" expansion link, i see following (mentioned above):
There was a temporary DNS error. Try refreshing the page.
Error Code: INET_E_RESOURCE_NOT_FOUND
Now, if i click on the "Fix connection problems" button, the Windows Network Diagnostics window popups up and says:
The remove device or resource won't accept this connection
If i click on "View detailed information" link at the bottom of this popup, i see following details:
The device or resource (localhost) is not set up to accept connections on port 'X' (where X is my localhost dev port).
Summary:
In the end, there is no real reason why port 'X' is not working any more. If i change the port number from Visual Studio the web app will run. But as i mentioned before, restarting Visual Studio will allow me to run for the 1st time.
* Updated *
I found a great work-around solution. Instead of running (F5), i simply choose a view (.CSHTML) and execute that view itself (right-click --> View in browser). This seems to work just fine every time without messing up the port.