asp.net waiting for localhost forever - asp.net

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
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.

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

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.

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.

Sometime it happens due to issue with symbols loading.
Try this
Go to Tools -> Options -> Debugging -> Symbols and click the button 'Empty Symbols Cache'

In my case there was a problem with configuration of Visual Studio stored in /.vs folder inside solution directory.
During development a lot of changes were made in IIS configuration: creating new sites, replacing old ones, changing pools etc. So Visual Studio have lost "connection" to given site and its pool. After deleting of /.vs folder and launching of Visual Studio the new execution configuration was created and it was properly attached to current IIS configuration.

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

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 (^_^).

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]

For me, on aspnet core it was a problem in Configure() method hanging because of exception

In my case, the problem was that IIS didn't have sufficient permissions to the website.
I fixed it by granting Full Access permission to the IIS_IUSRS user on my entire website code folder (as in yoursolutionfolder\yourwebsiteprojectfolder).
Then after granting permissions, I had to run iisreset for it to start working.

I was Able to Connect to Application when asp.net waiting for <...> modal appear then i Click Browse in my IIS
note : You must create the Application Pool and Website manually and set the website pool to Application pool that you have been created before.

Please check WEB.CONFIG file, I had a similar issue where my site got "Waiting for" forever. Tried restarting the website, laptop nothing happened, it was prompting me for SQLServerExpress, I realized that the database server was not correct on my web.config so I changed it to the correct one which resolved my issue

In our case, the issue was Symantec Endpoint Protection. By turning off the Enable Network Intrusion Prevention option on the Network and Host Exploit Mitigation module, Localhost was working again.

Related

Host ASP.Net MVC Site

I've created a site using ASP.Net MVC that is meant to be stored on a local machine at my place of work. The intention is to have the site stored on this machine, but then accessible by all the other machines within this building.
I've followed Microsoft's tutorial as well as Code Project's tutorial, but I am not having very much luck. The binding is just the localhost, port 80, with * for the IP address. The URL is localhost/GrantTracker.
I've opened the ports within the firewall, checked the permissions on the directory (which is just within wwwroot), tried having the site take the place of the default IIS site (as Microsoft tutorial has you do) and tried having the site stand on its own with its own port (per Code Projects tutorial).
On the host machine I am receiving the standard "This site can't be reached, localhost refused to connect" which feels like either a port or permissions problem. I must be missing a step, but I can't seem to find what it would be. I am new to hosting sites through IIS so forgive me if I am just missing something basic.
I find it a bit strange too because my project uses Windows Authentication and when the site is first visited it performs that initial check with the user, authenticates, but then throws me the error.
Anyone have any ideas? Thanks in advance.
start simple,
create a simple html page, create an IIS application for it, on port 80.
Check and make sure you can see that page from another computer using the internal IP address of the the host machine so something like:
http:\\192.168.0.3\hostapp\test.html .
You can see the proper URL by running it from IIS, this will give you the entire URL you need, with localhost then just replace localhost with the IP address of the host machine to see it on other machines.
Do this in the original IIS folder so you don't encounter any folder permission issues. If you choose another folder you'll have to give access to the Network Service user ( i think, can't remember now, but there is a specific user that needs access to the folder where the website is deployed )
if you can see the page then deploy a proper website and do the same thing. Make sure the app pool is created correctly and it's up and running, then access it again on other computers and it should work.
Port 80 should be open by default so that should not be an issue.

IISExpress - Get the site to identify its own SSL port binding

OK, so a little background on the environment configuration at present:
Using VS2017
IISExpress folder present in my documents folder with applicationhost.config file
When I run my web project in VS2017, it runs successfully through IISExpress. If I view the IISExpress config window then it shows me that my app is running successfully and that it's using the config from my source\repos folder and not the main IISExpress folder in my documents. If I look at the config file in the IISExpress folder there is no mention of the bindings for my currently running application (makes sense, as it apparently uses a different config file).
However, within my app I need to be able to use the Microsoft.Web.Administration toolset to try and identify the port bound to https for the current site to handle a redirect to a page that must be secure. In the production environment this is just handled by pushing to https:// because we know an SSL certificate will be present. But, when debugging locally I need to switch to SSL and take the port number otherwise my redirect is broken, for obvious reasons.
Using _Manager_ServerManager As New ServerManager
For Each _Loop_Binding As Binding In _Manager_ServerManager.Sites(System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteName()).Bindings
If (_Loop_Binding.IsIPPortHostBinding) AndAlso (_Loop_Binding.Protocol.ToLower() = "https") Then Return _Loop_Binding.EndPoint.Port
Next
End Using
The code above causes an error when running, as the current site does not exist within _Manager_ServerManager.Sites. If I inspect this property then I can only see the applications that are configured in the configuration file taken from the IISExpress folder in my documents, not the current site!
I'm really scratching my head on this one, is there any way programmatically that I can get this information for the currently running website?!
EDIT
Based on some of the comments below, more clarity has been requested as to what I'm actually trying to achieve. The website typically operates on standard HTTP, however, when progressing to one particular page for security reasons we need to shift to HTTPS:
Response.Redirect("https://" & Request.Url.DnsSafeHost & "/my-page.aspx")
When debugging this website locally, using IISExpress, this results in you being redirected to https://localhost/my-page.aspx, which is incorrect because the site runs on a port of localhost (i.e. http://localhost:64905 and https://localhost:64906). This means that I cannot just append Request.Url.Port onto the end of DnsSafeHost, because it will not be the HTTPS port required. Thus, so that we can run this project locally on our dev machines we need to automatically switch the port to the HTTPS version so that we can continue seamlessly without any disruption and having to manually rebuild the URL each time we get redirected.

System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0

Firstly, I am aware this problem has been dealt with before here, and the solutions are always corrections to the connection string.
However, in our case, the connection string is correct, because most of the time it works fine. What happens is at some point the site 'stops' and starts logging this error. Simply recycling the app pool clears it, and everything is good again until the next time. A site might run fine for hours or days, but then it falls over and every request logs this error.
Since it is a transient error, I suspect it is somehow memory or service related? Either some kind of service that handles the connection from the ASP.NET site fails within the app pool, or there is some shortage of memory so whatever process is required to handle the connection fails.
It is not just a single server, I have seen this issue occur on various customers' servers, so I don't think it is some obscure glitch with a particular server. I have also seen sites that were running fine for a long time start to experience this issue (which suggests to me it is related to resource availability).
For the sake of completeness, this is the connection string from a site that exhibits this problem:
<add name="SQLConnection" connectionString="Data Source=localhost\sqlexpress;
Integrated Security=True;Initial Catalog=databasename"
providerName="System.Data.SqlClient" />
But like I said, this works absolutely fine for hours/days, until the problem occurs.
Just surfing with error message and got one link from Microsoft.
Seems to me like your problem.
Can have a look on this.
http://social.msdn.microsoft.com/Forums/en-US/9f191038-dbf6-4306-8f66-ec211a1e933a/format-of-the-initialization-string-does-not-conform-to-specification-starting-at-index-0?forum=adodotnetdataproviders
Thanks
Can you please check following points:
Make sure the account has full permission (both read and write) on folder:
"C:\INETPUB\WWWROOT\BE SITE WORK(FINAL)\4SIGHT\WEBSITE\BARAMATIESTATES\BARAMATIESTATES\”
I recommend that set “C:\INETPUB” folder allow all user access and edit, at least give full administrator right to IIS account.
2 Make sure IIS account is sysadmin of SQL Server.
Setting IIS Permissions for an Object
You can set permissions for any object in IIS, including Web sites, folders, files, and scripts. To set the permissions for an object in IIS:
Log on to the Web server computer as an administrator.
Click Start, point to Settings, and then click Control Panel.
Double-click Administrative Tools, and then double-click Internet Services Manager.
Right-click the Web site that you want to configure in the left pane, and then click Properties.
If you want to set the permissions for a Web site's home folder, click the Home Directory tab.
If you want to set the permissions for a folder in a Web site, click the Directory tab.
If you want to set the permissions for a file or a script in a folder, click the File tab.
Click the corresponding permissions that you want to set for the object.
To turn on script processing for a Web site or folder, click Scripts Only from the Execute permissions list.To turn off script processing, click None.
Click OK.
if the issue still persist let me know :)

IIS 7 not showing virtual directory mapped to another machine

I have an issue with IIS7 when mapping virtual directories to another machine.
This is my setup:
my Web APP is running on the web server (let's call it WEBSERVER). Windows Server 2008, IIS 7.
I got some assets/images in an assets server (let's call it ASSETSSERVER). Windows Server 2003, on the C:\Assets folder, shared as \\ASSETSSERVER\Assets
Servers are in a workgroup, not a domain. This is something beyond my control, which I can't change.
Following the recommendation of our network team, I configured the app pool to run under the user WEBSERVER\portaluser
In my web app, I define a virtual directory. I map it to \\ASSETSSERVER\Assets. In the log in credentials, I specify the user ASSETSERVER\assetsuser (which exists). The 'Test credentials' buttons show that i am authenticated OK and that I have authorisation.
At first, I got a 500.19 error telling me I could not log in. This post revealed the solution: I had to create a WEBSERVER\assetsuser user with same password (counter-intuitive, but it worked).
After that, my assets still refuse to display. I now get a message similar to this:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred loading a configuration file: Failed to start monitoring changes to '\\ASSETSERVER\assets'.
Source Error:
[No relevant source lines]
Source File: \\ASSETSERVER\assets\web.config Line: 0
I have done some extensive googling, and I have tried the following:
Modified the local policy to allow WEBSERVER\portaluser to impersonate other accounts after login, as suggested here (it's for Windows 2000 Server but it was worth a try!)
Added permissions to everyone to the \\ASSETSSERVER\assets, as indicated here (bottom answer)
Added read/execute/list permissions to the c:\ drive in ASSETSSERVER to the ASSETSSERVER\assetsuser user, as suggested here (method 3)
I edited the registry key to stop IIS from monitoring the folders for changes, as indicated here (the writer claims that it's not related to IIS but I am quite certain that IIS does monitor the folders for changes in web.config)
I have configured allowsubdirconfig="false" in applicationHost.config as indicated here
None of these solutions have worked, and I am running out of ideas of what to try. It seems like I'm so close yet so far. Any suggestions?
After several of work I found the solution to this issue.
It was as simple as creating a user called "portaluser" (the same as my app pool identity user) in ASSETSSERVER.
This is counter-intuitive: I explicitly told IIS7 to connect to ASSETSERVER as the assetsuser server, but it was still using portaluser to check for the existence of web.config (and monitor for changes).
Having seen that, I decided to use the same account to run the app pool and to connect to the remote virtual directory. I just used 'assetsuser' instead of 'portaluser'
Hope this helps

IIS7 and Classic ASP and Applications and Paths

I yesterday received a zip file containing an old asp site from 2005. Its came in a folder called ivx.
I've unzipped ivx to c:\inetpub\wwwroot and then created an application in IIS called ivxapp and pointed it to c:\inetpub\wwwroot\ivx. Now when I type http://localhost/ivxapp, I am able to access the index page.
My problem is, whoever designed that site, designed it when IIS5 or IIS6 was around. He's used paths like more... which leads to http://localhost/new_posts.asp and not http://localhost/imagevertex/new_posts.asp
The whole site is some 21000 lines of code and contains many many references like this. Then comes the problem with <!--#include virtual = "/common/adminverify.asp" -->
Instead of having to manually edit the entire code, do you know a way to get things going?
This site worked perfectly well on a production server. Right now it's on my local machine on Windows 7 64 home premium.
Yes, you need to give this site a root-URL of its own, and not run it in a subdirectory of your localhost.
This is more of a web-administration question, but what you need to do is either run it under "localhost" directly, or add a domain-name to your network to run this site under.
The easiest for you right now is probably the first option.
If you aren't running a different site under localhost already:
Go to the IIS manager and click the 'localhost' site. On the right side of the IIS interface you can change the basic settings. Point the physical path to the ivx directory. You can reach the site directly on http://localhost.
If you are already running a site under localhost you need to keep:
Now, if you -are- already running a site on your localhost, the second easiest option is to run the ivx site under localhost, but on a different port. To accomplish that, click on the current ivx site in IIS, change the path in the same way as descibed above, and after that click on "bindings" in IIS, and change the PORT for the ivx site to something other than 80, for example 81.
The ivx site will then run on http://localhost:81, your current localhost will still run on http://localhost.
The hard way: adding a host to your network or PC:
The last option is to add a new hostname for the site to your network. You can add an A-record in your DNS for the ip-address of your server or add a host name to your HOSTS file in Windows on your server ("server" in the sense of the machine that runs the site, which can also be your local machine)
You can add a made-up name to the ip-address of the server, and in IIS' bindings add that name under "host name". this way you can run two different sites on the same machine, the "host name" seeting in IIS will make sure that calls to that specific hostname will reach the correct site. Adding it to the DNS of your network, or the HOST file in Windows will make sure the name is resolved to the correct machine (your webserver).
This last option is a little tricky of you've never done something like this before, but the first option works just as well.
Good luck!
Erik

Resources