asp.net waiting for localhost forever

2019-01-26 05:40发布

问题:

Suddenly this morning I turned on my computer and launched visual studio... And no matter what I tried and whether I run or debug, and whatever the browser is ( chrome / firefox / IE 11 ) it is waiting for localhost forever.

If I deploy it to azure, by just checking in ( continuous integration ) it works like a charm: http://couleur-emotion.azurewebsites.net/ ( I'm remaking my mummy painting website in order to learn ASP.net MVC )

I've read both:

  • Waiting for localhost, forever!
  • How to figure out why my local host site takes so long to load?

As I write, it has been waiting for localhost for more than 15mins. I restarted VS, even rebooted the computer... tried the ipv6 disable stuff on firefox...etc

I noted ( do not know if it is useful ) that Replacing localhost by 127.0.0.1 throws:

Bad Request - Invalid Hostname
HTTP Error 400. The request hostname is invalid. 

also my C:\Windows\System32\drivers\etc\hosts ( unchanged )

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost

Any idea ? I've not been able to show a single localhost page in 3hours.

回答1:

Check firewall for blocked ports, change dynamic ports of application to some fixed port.



回答2:

Okay, I've found that this happens (on a server) when you've hardened security properly.

For example, you no longer blanket apply IIS_IUSRS to the wwwroot but setup proper accounts for each App Pool and are setting the NTFS perms properly.

The problem is that the worker process/ASP.NET wants to enumerate the files in the folders "leading up to" your website root. I think it wants to look for web.config files etc.

The failure to produce an error, i.e. the infinite loading is a bug in my opinion.

e.g. i:\wwwroot\project\virtual\base

You'll need to apply IIS_IUSRS group read access to wwwroot, project, virtual but not base. The trick is to only apply to the current folder, i.e. don't apply to subfolders and files.

Apply read rights just to the worker process/AppPool identity to the base folder.

If IIS_IUSRS has read rights to the whole tree, then all worker processes will have read access to all other website base folders and contents, such that a compromised site will be able to access data/config in other sites.



回答3:

I had a similar issue where my site got "Waiting for" forever. Tried restarting the website and nothing.

I was not able to reboot the machine (I am pretty sure that it would solve) so I kept investigating what could be.

I found out that, in my case, the solution was to change the "Application Pool" of the website. It appears that the current one crashed or something like that (I was able to stop it but not start it back again), so I created a new Application Pool and the site started working again.



回答4:

Restarting the IIS may work as it will end the current instance and run your web page in a new instance.



回答5:

I had received a project where the webconfig had port number mentioned along with the server like this.

sqlConnectionString="Data Source=<<SQLInstanceName>>\SQLEXPRESS,<<Port>>;Initial Catalog=<<DBName>>;Integrated Security=false;User Id=<<UserName>>;PWD=<<Password>>;"

After removing the port number from connection string, the error message disappeared and code began to work.

sqlConnectionString="Data Source=<<SQLInstanceName>>\SQLEXPRESS;Initial Catalog=<<DBName>>;Integrated Security=false;User Id=<<UserName>>;PWD=<<Password>>;"

I am relative new to ASP.net. Dont know if this is going to cause problem elsewhere (^_^).



回答6:

My issue was a result of a not having proper credentials on the working website folder. If you arent sure grant full control to the folder as a test. User = IIS AppPool[app pool name]