Newly created Asp.net Web App can ONLY RUN ONCE (in VS2017) - asp.net

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.

Related

IISExpress not connecting when trying to debug

I'm working a ASP.NET MVC project in Visual Studio 2015 (14.0.25431.01 Update 3) that runs IISExpress to debug the application. However, sometimes (and I haven't figure out what the trigger is) when I debug the application my browser will open to the correct URL but it will just say "Unable to connect".
If I try to refresh the window nothing changes. If I check Visual Studio it still says it's debugging so the debugger or IIS doesn't seem to have crashed. Sometimes if I just click Restart it will work fine. However, sometimes this error continues and I have to kill the IIS process. I've tried deleting the files under .vs\config but that didn't help.
Is there any way to fix this or anyway to find some logs to see whats happening? This started in the last few weeks and it starting to drive me crazy.
Edit
Happened again and tried connecting via Chrome as well as my usual FireFox. Looking at the developer tools in Chrome I'm seeing the ERR_CONNECTION_REFUSED message.
I decided to check the Windows Event Viewer and found that it looks like IIS Express can't bind to the port.The error message is:
Unable to bind to the underlying transport for [::]:12345. The IP Listen-Only list may contain a reference to an interface which may not exist on this machine. The data field contains the error number.
But why it can't bind to that port I don't understand.

Failed to map the path '/' Visual Studio 2013 IDE (Even as administrator)

I use to be able to connect to my Test Server source code via a Network Drive.
I have mapped it to letter K.
My computer (since last restart) won't run the IDE properly, and always displays the error ASP.NET runtime error: Failed to map the path '/'. at the top of the .aspx file.
I have tried the following:
Starting Visual Studio as administrator
Ensuring that my user has FULL rights to the source code folder (both from the network drive and the server)
Given Network Service and Network users on the server full control over the test server source code folder.
Changing the AppPool identity on the test server to use my username (as I am administrator on the server as well).
Creating a new website project and mapping it on another network drive (Still doesn't resolve the problem).
When I access the test server via my web browser I receive no errors. So I know there is no errors in my code.
If I open the IDE on the server using remote desktop then it works with no errors.
I can live with the error on the top of the page, however when I try to access a DataSet or a Control on the page then it doesn't register the control or function as an existing function.
I am now at a complete loss as to how I am going to fix this.
Any ideas on what could cause this issue and how I could fix it?
I found a work around to the problem by opening the code directly using the IIS on the server.
What I did was click on File -> Open Website, in the open dialog, on the left, I clicked "Local IIS", found my TestServer and clicked open.

Unable to start debugging on the web server.

Ok so I've set up IIS on my laptop, I then went to visual studio and created a new test project called IISTest, right clicked the solution > properties > Web > and choose > Local IIS and created the virtual directory, message popped up saying directory was created successfully, I then open IIS to make sure its there and below is what I see - seems normal:
I then run the project and got the follow message:
Unable to start debugging on the web server. Unable to connect to the web server. Verify that the web server is running and that incoming HTTP requests are not blocked by a firewall.
I off to google I went, found this which explains the problem I'm experiencing http://saiabhilash.blogspot.com.au/2012/03/unable-to-start-debugging-on-web-server.html
When I open IIS and try to see if its running on the right hand side this is what I see, I don't get the option to select start/stop or reset:
Would anyone be able to suggest what's wrong please.
You start or stop/recycle the application pool. On the left pane, Application Pools are above the Websites, the options will now appear on the right pane.
You can also run Appcmd.exe, for Application Pool operations
or
Run iisreset from the command-line, for IIS Server Wide operations

VS2010 Debug web app causes "cannot start application" and "access denied" errors

When I try to debug my VS2010 web app (F5), the IE web browser windows pops up but then freezes, and my VS2010 IDE window pops up an error message:
Unable to start program 'http://localhost:nnnn/Login.aspx'.
Access is denied.
I'm running VS2010 (10.0.30319.1), targeted to ASP.NET 4.0 (4.0.30319), in non-administrator mode, with ASP.NET debugging enabled, on 64-bit Windows 7 Enterprise SP1, with IE 9 (9.0.8112.16421 with update 9.0.29).
This web app and others I work with have been working just fine for several months, but they all started to misbehave in this manner a few weeks ago. At first, the first time I tried to debug (F5) I'd get the error, but after clearing it and closing the IE window and trying F5 again a second time, the browser would come up just fine. I assumed it was just some glitch, so I tolerated it.
Lately, though it has gotten worse, to the point that 90% of my attempts and re-attempts to debug the web app cause a hung browser and the error. It sometimes works, but most times it doesn't. I have to kill the handing iexplorer.exe processes to clean up my user space, otherwise I eventually get a message about not having enough files to start the browser. I try rebuilding, stopping the ASP.NET Development Server process, even exiting VS2010 and restarting it, but I can't seem to find the magic sequence of events to get it to work.
If I start without debug (Shift-F5), it works, but two IE web browser windows are opened, and both attach to the web app. I don't know if this is related to the first problem. And needless to say, this does not really allow me to debug my code. I tried attaching to either of the IE processes, but I still could not get the debugger to actually debug the executing app. (There is a message about no symbols being loaded for the attached process.)
Most of the solutions for this problem I've found say something about running with administrator access. I cannot do this, however; I work at a large financial company, and developers are not allowed to have local admin rights on our PCs. I don't control system patches, but I can request Help Desk ticket to resolve the problem; but I'd like to resolve this problem myself if it is a fairly simple configuration problem on my part.
Addendum
I should also add that I am not using IIS (because I don't have it installed on my system, and I can't use it anyway because I don't have local admin rights), but instead I am using the built-in Visual Studio Development Server. I've also selected a specific HTTP port number for it to use. Also, all of the directories I'm been using were created by me (as part of my project workspace), so there should be no access permission problems.
Like I said, I can sometimes get a debugging web session started, but most of the time I can't. So whatever is causing this problem, it is probably something intermittent.
This tend to occur when you try to run the full version of IIS rather than the Visual Studio Web Server or IIS Express. Have you tried running IIS Express instead? I think there's support for IIS Express that came with one of the later updates to VS 2010?
IIS proper definitely requires full admin rights in order to attach a debugger because full IIS runs under a system account rather than your own account. IIS Express (as well as the Visual Studio Web Server) however should run under your own user account and so debugging should work on the local machine even with a non-admin account.
One issue that might cause problems is directory permissions. Make sure that the folder where your Web files live are read/execute accessible through the file system for your user account.
Finally make sure you don't have some other instance of a Web service running on the same HTTP port.
I am having the same issue, it works when i don't choose to debug but CTRL+F5 to start it. F5 Debugger al

Why does ASP.NET show this error?

I have installed Visual Studio .NET 2005. But when I am trying to execute an asp.net application then I am getting the following error:
Unable to open the Web 'http://localhost/adiii'. Could not find a Web server at 'localhost' on port 80. Please check to make sure that the Web server name is valid and your proxy settings are set correctly. If you are sure that everything is correct, the Web server may be temporarily out of service.
Click here to view screenshot of the error I am getting
Can anyone please tell me the solution of this problem. As we know there is embedded Web deployment server inside VS2005 then why its giving me this error??
It looks like when you created the project, you selected HTTP for the location instead of the default, File System. HTTP means you have an existing web server (not Visual Studio) that you want to run and test your project on (and where Visual Studio will attempt to find your source code).
Create a project and select File System to create a project on your harddrive that will be run using Visual Studio's internal web server (you can then publish/deploy the project to a real web server when you want)
Are you explicitly have defined that the internal web server should run the application on port 80?
The default behavior is that it runs on a random port.
If your settings are ok, then it might be a port conflict with another web server on your machine (Apache, IIS).
Sometimes even a Skype can okuppy port 80 and cause similar problems.
Update:
Now i see - you're using Web Site project, and we assumed you're working with Web App project instead.
In this case, the procedure is slightly different:
You select the project in Solution Explorer and open Property Pane. Here you should be able to identify two properties for the project: Port number and Use dynamic ports. I assume your first property is set to 80, and second one to false. Change the second one to true and you should be able to fix the problem.
There's a very good chance that you created the project in VS2003 and upgraded it to VS2005. VS2003 uses HTTP (a local installation of IIS for example), whereas VS2005 projects use the built-in server -- most likely, the upgraded project is still trying to use the local IIS which doesn't exist.
Do this: Right click on your project, choose "properties", and navigate to the "Web" tab on the window which pops up. You'll get a screen which allows you to choose which server you want to develop on, then make sure the buttons next to "Use Visual Studio Development Server" and "Auto-assign port" are checked.
Here's a visual reference if you need one:
http://img24.imageshack.us/my.php?image=confignw0.png
You should be be good to go now.
Visual Studio does have an embedded web server, but it never operates on port 80. Your URL clearly points to port 80.
The most likely problem is your program itself working inappropriately, but without code I can't help much more.

Resources