I have a C# Asp.net web project made in Visual Studio.
The project runs on a certain port (57243) and I made other programs that were testing the web service etc to use "localhost:57243".
Recently I tried running the project in Jetbrains' Rider IDE because of whatever reasons I made up at the time.
The only issue I am having now is that the web service runs on port 5001 and I cannot find any property to change the base url or the host port to make it work.
TLDR, I am looking for this option inside the Jetbrains' Rider IDE:
This can be done inside the Rider IDE if you like.
If you edit the run/build configuration you are using when you hit F5 and then edit the environment variables you can add the ASPNETCORE_URLS environment variable which will run the app using the port specified as shown here.
Rider Run configuration environment variables
Steps to edit the setting
Open the edit screen for the run/build configuration
Click the ellipsis on the environment variables edit box to edit
Click the plus (+) symbol to add a new evironment variable
Set the name to ASPNETCORE_URLS and the value to http://*:57243
Save your changes and run
#Sasquatch's answer works for ASP.NET Core only.
For plain old ASP.NET, with IIS Express, we can go the project properties, Web section, and then
Make sure "Server type:" is "IIS Express".
Check "Generate applicationhost.config". [*]
Set "URL:" to "localhost".
Set "Development port:" to whichever port you want ("1234" in this example).
Click "OK" and restart the web application.
This will rewrite the generated applicationhost.config file (in .idea\config\ folder) with your selected configuration.
[*] If "Generate applicationhost.config" is unchecked, you should edit that file directly, like #WWietlol's answer suggests.
It turned out that the option in Visual Studio just changes the application.config in the .vs folder.
A similar file in the .idea folder had the properties of the ports.
Changing it in that file fixed it.
To set the Port on JetBrain Rider v2019.1, in the solution view, open the launchSettings.json file in the Solution > Project > Properties folder. You will be able to set the applicationUrl port for both the https://localhost:{port} and http://localhost:{port}.
Make sure you restart the that app, to use the new port.
Removing all files in the .idea folder helped me. Rider showed me the initial window of to configure my project from scratch and imported all necessary settings (like environment and url) automatically.
I was unable to configure a root as per rsennas answer with an ASP.NET MVC project.
Neither Rider nor Visual Studio control the configuration of the web server (IIS Express), instead they both just generate an applicationhost.config file that they pass to IIS Express. You should see something like this when you start the application from Rider
C:/Program Files/IIS Express/iisexpress.exe "/config:C:/foo/.idea/config/applicationhost.config" "/site:foo" /apppool:Clr4IntegratedAppPool
Starting IIS Express ...
to spot which applicationhost.config file is used. Specifically, the relevant section looks (ish) like this
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<!-- ... -->
</site>
Unfortunately, neither Rider nor Visual Studio is particularly good at generating this file. Rider tends to yield incorrect configurations and Visual Studio tends to be inconsistently formatted ¯\_(ツ)_/¯
You can use a diff-tool (like vimdiff) to compare the two (preferably after harmonizing the formatting) and pull the relevant configurations from one file to the other.
Specifically, it appears IIS Express requires a root website. In my case I had to change something like this
<site name="foo" id="1" serverAutoStart="true">
<application path="/foo">
<virtualDirectory path="/" physicalPath="C:/Foo" />
</application>
</site>
into
<site name="foo" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<application path="/foo">
<virtualDirectory path="/" physicalPath="C:/Foo" />
</application>
</site>
What I'm doing:
Opening Visual Studio Community 2015
File -> New -> Project
Under Visual C#: Web -> ASP.NET Web Application
Web Application
And press f5 for the popup error "unable to connect to web server 'IIS Express'."
Deleting applicationhost.config, located in Documents\IISExpress\config, doesn't change the error message. (There's also an IISExpress folder in program files and program files (x86).)
Something I noticed, and I don't know if it's a problem:
Referenced file 'lib/jquery-validation/jquery.validate.js' not found.
I got a dump with rawcap but I don't notice much in there. Some of what was there:
"Framework":{"FrameworkName":"DNXCore,Version=v5.0","FriendlyName":"DNX Core 5.0","ShortName":"dnxcore50","RedistListPath":null}
I don't notice a problem, but I have the network data if that can help figure out why I cannot connect to the web server. I get a RST,ACK immediately so I'm guessing the port is closed and whatever this web server is, isn't being setup.
More on this problem: 800700c1 error from /trace:error
I've tried:
deleting applicationhost.config (and changing port number)
running visual studio as administrator
deleting IISExpress folder in Documents (changes error message until the folder is reinstalled)
toggling ssl off and on, copying url to launch box. (note: I'm not using ssl)
clearing all sfc /scannow errors
starting iisexpress with x86 version and 64-bit version
After installing Update 2 for Visual Studio 2015 I started getting the same error. I tried everything above with no luck. However, I found a solution that works for me:
Delete YourSolutionFolder\\.vs\config\applicationhost.config file (note: .vs is a hidden folder)
Open Visual Studio, right-click on web site > Properties > Debug tab > Web Server Settings > App URL - change port number.
If you have IIS configured to use the same port, (stop the application / use different port) and try again.
Exit VS and delete the (project)\.vs\applicationhost.config file. Restart VS. It should start working.
Try using a different port. I just set up a new Core 1.0 RC1 project and got the same error.
Right click web project
Debug tab
Toggle Enable SSL off and on again, it should generate a new random port
Copy the SSL URL and paste into Launch URL box
Run the project
Worked for me (TM).
Answer from: https://stackoverflow.com/a/28650554/134761
I had this issue on .net core 2.1, visual studio version 15.9.6. When i deleted the .vs folder, i reopened visual studio and the problem was still there. The solution that worked for me below:
Delete .vs folder (it is a hidden folder).
Restart Computer.
Other Solutions:
Close Visual Studio, delete bin and obj folders from the project folder. Open Project then rebuild solution.
Try running Visual Studio as Administrator.
Clean Solution then rebuild
Clean Solution. 2) Exit Visual Studio. 3) delete .vs folder 4) Re-open Visual Studio
Restart machine (if you can afford to)
Copied my comment to an answer by request.
For Net Core 2.2 project - After a MASSIVE struggle and trying everything from deleting .vs folder, deleting IIS Express configs, changing port numbers, changing bindings, and to running VS as admin I FINALLY fixed issue by
closing VS,
deleting launchSettings.json
opening VS which re-generated launchSettings.json.
It was not apparent that the file was corrupt or incorrect or even when it changed to cause failure.
I faced this issue in .net core 2.0 when I update my project's port number.
I was able to sort out issue in two steps :
STEP 1 : DELETE .vs folder which is hidden inside main solution folder. (close visual studio before this) then when you start again visual studio, this folder and file (applicationhost.config) inside it will automatically create by visual studio.
STEP 2 : For multiple startup projects, if you are still facing issue then one by one run project as startup, and then run as multiple startup project.
I had the same issue, i was able to solve it by changing the Port number.
Right click on the project and select properties
Go to the Debug section
Under Web Server Settings change App URL port [just increase by one :)]
In my case that was some other application listening on the same port which IIS Express trying to attach to. I have to run netstat -ao to see PID of process which is use same port and shutdown application. In my case application was Viber.
I just changed my profile from "IIS Express" to "MyProjectName" (which I think is using kestrel as the http server instead of IIS) and now it's working fine:
Run VisualStudio with administrator privilegies and run the project. Then close VisualStudio and all errors and run VisualStudio again with the normal user.
This did it for me.
Looks like that IIS has to write something to some config with admin privilegies (port 80 didn't work with normal user but port 6767 worked fine).
Many of these answered don't fully address the issue at hand. The real problem for me was that I had two bindings using the same port in my applicationhost.config file AND I hadn't opened up the port to my second (non localhost) binding. VS will allow you to still run under these circumstances but only if you are in admin mode (hence all of the answers above).
You are essentially creating two IIS express instances of your app on the same port, so changing one of the ports in your applicationhost.config file will allow you to proceed. There are two different applicationhost.config files however. You will want to select the one that has the binding IP and port that you see in your project's properties
.
Go to the folder where you can see your project solution and project folders (show hidden items in File Explorer). Navigate into your hidden .vs folder -> "YourAppName" folder -> config. It should contain the binding info you saw in your project's properties.
Example:
<bindings>
<binding protocol="http" bindingInformation="*:7000:127.0.0.1" />
<binding protocol="http" bindingInformation="*:7000:192.168.0.5" />
</bindings>
Change one of those port numbers to something other than "7000" so that you aren't trying to use the same port.
In my case, I'm using a 192 address which is not a localhost address, so I need to use some netsh commands to open that port and ip up. Here is a Link that shows how to open up ports for IIS Express to allow remote connection. Running as a normal user will not work unless you run those netsh commands listed.
Here are the netsh commands:
netsh http add urlacl url=http://192.168.1.42:58938/ user=everyone
netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=58938 profile=private remoteip=localsubnet action=allow
Copy those commands and run them in cmd with ADMIN privileges and with YOUR ip address and port number.
TO CLARIFY
Really a lot of answers here are the same and say something like "Restart and it magically works again".
Well, 9 out of 10 times people have this issue like the OP it is because THE IP-ADDRESS IS ALREADY IN USE.
ANSWER
There could be 2 ip-addresses that are in use. Both of them you can find by:
1) Right-clicking on the start-up project
2) Click on "Properties"
3) Click on the "Debug" tab
Here you see your "App URL" and your "SSL URL".
If your "App URL" is in use, just change it there and save it and it should work again.
If your "SSL URL" is in use, close down VS, delete the "applicationhost.config" file in the hidden .vs folder of your project and open VS up again.
The solution that worked for me was to:
Close the VS project
In File Explorer, navigate to the project and delete the entire ".vs" folder
Restart the project
Run as "Debug"
Works
Apparently, it has something to do with the "applicationhost.config" file.
Enjoy!
If you can afford to restart your machine then do it 👌, this fixed my issue after almost an hour of trying to fix this issue with no hope 🤯.
I was able to toggle this error by changing a single thing. In my ASP.Net Core 1.0 RC2 Web Application project's launchSettings.json file:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:18177/",
"sslPort": 0
}
},
to
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18177/",
"sslPort": 0
}
},
I had changed to https in an attempt to run the project using that protocol. Apparently this is not the place to make that change. I suspect it is creating multiple bindings on the same port, and IIS Express doesn't like that.
I had this same issue, but the way I fixed it was by going to the applicationhost.config and remove a port which was not added by me (IIS Express I would guess) which placed my specific port site on another port.
Here is what the config file had for my bindings:
<bindings>
<binding protocol="http" bindingInformation="*:54764:localhost" />
<binding protocol="https" bindingInformation="*:44360:localhost" />
</bindings>
I removed the first bindings item as the only port I wanted was 44360. My config file now looks like this:
<bindings>
<binding protocol="https" bindingInformation="*:44360:localhost" />
</bindings>
Now I don't see the error when I debug.
I also noticed my second API in my project had port 80 also assigned to it, I removed that as well.
delete bin and obj folders from the project folder and rebuild.
For me the problem was that an other process was using the same port. (In my case it was outlook that was using the same port as my site and thus my site couldn't start)
Yes you can change the local port, but if you are running an API or something that other applications need, you don't always want to do this.
To get a list of what applications are using what port open CMD and type "netstat -aon"
You will get a list of ports. Find the port that your site should use, or that you want to use and write down / remember the PID.
Now open task manager and click on the tab 'details'. Find the process with your PID and end it. Now you should be able to start IIS Express with that port.
I just Cleaned my solution, Then Re-Built it and finally hit F5 and it worked! So simple.
I won't pretend to fully understand what MS bug creates this problem, but here is another potential solution:
In the .vs/config/applicationHost.config file, find the section for <system.applicationHost><applicationPools>. Under the pools, ensure that the managedRuntimeVersion attribute value matches the value which is in the IIS config for the system (and/or the version of the .NET framework which is installed).
For example, you may find (as I did) that the generated file has:
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
In my case, you would replace this with:
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0.30319" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
Note the replacement from "v4.0" to "v4.0.30319". This resolved the issue.
What appears to be going on:
I believe that VS is generating an applicationHost.config file with "default" versions for the .NET framework, which may not match the specific version which is installed/configured on the system. You can debug/observe this issue by tracing the execution in Process Monitor, and finding the command line for iisexpress.exe. Running this command with /trace:error added yields a more informative message about a failure to preload the CLR with version v4.0. To wit:
Starting IIS Express ...
Failed while trying to preload CLR version v4.0. hr = 80131700
Failed to initalize the W3WP_HOST hr = 80131700
Process Model Shutdown called
Unable to start iisexpress.
Anyway, figured this might be helpful to someone else, since it's common enough to have multiple references online with bad information, and I've personally hit it a few times now.
For me, IIS Express was not accessible when I added iplisten on DOS Prompt like this: netsh http add iplisten MyIPAddress. I fixed it by deleting the iplisten like this: netsh http delete iplisten MyIPAddress.
If you are using VS 2017 or VS 2019 with ASP.Net Core, you can directly go to launchSettings.json under Properties folder and just change the Port number of applicationUrl key for iisSetting.
I just encountered the same problem and I killed all the "iisexpress.exe" processes that were still running. That worked for me!
Try this first if it was working and suddenly stopped:
Close Visual Studio
Kill iisexpress.exe processes
Reopen Visual Studio
Mine happens as soon as I add a new binding inside the applicationhost.config, running as administrator fixed the problem.
Just close the visual studio and reopen and execute.
It worked for me.
My solution (for .net core 2.0) was that i had forgot to add the port number in the applicationUrl, under iisExpress in launchSettings.json
"iisExpress": {
"applicationUrl": "https://localhost:50770",
"sslPort": 50770
}
I was able to resolve this by restarting my computer. I tried a few things unsuccessfully and finally gave up and restarted my computer. It has been working well now for a couple of days after I restarted. Probably the result of some process that was hung.
For me, it was a mixture of following these instructions:
Delete your web application’s .vs\applicationhost.config and try
again.
And then, perhaps most importantly, running Visual Studio with admin privileges.
I added .UseUrls("https://localhost:<some port>/") to the Program.cs. This seemed to do the trick for me!
I have searched every topic and it seems that everyone got there problem solved already and I have tried all the possible solution they have provided or I am still missing something.
FireWall already turned off.
Ok so I am trying to access my IIS server Application that is currently run by VS 2013. Update 2.
when I try to access http://localhost:29790/ <- this to http://192.168.1.3:29790 which is my current IP on my local. It gives me 503 error.
I have searched for the solution and gives my a tons of.
applicationhost.config file
<site name="SMApplication(4)" id="10">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\DanZe3\Documents\Visual Studio 2013\Projects\SMApplication\SMApplication" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:29790:localhost" />
</bindings>
</site>
I have tried this.
*:29790:*
*:29790:
:29790:
by chaining the bindings. But it is still not working. I restart the PC or the VS as well. But the problem is, when I try to re-open VS. VS overwrite the applicationHost.config and add another binding.
As you can see in my site named "SMApplication(4)" (It has made 4 already!) This is automatic when I re-open the file
and then the bindings will be *:29790:localhost again.
Somehow Editing this bindings. Visual Studio will create another binding of the application, having another site named SMApplication(5).
I have tried to remove the localhost on the *:29790:localhost, but when I run the application it gives me.
Unable to Launch IIS Express Web Server.
The start URL specified is not a valid. http://localhost:29270/
I had a similar problem with a similar solution:
Scenario: I had the app pool running under an user account and it's password had been changed because it had expired. I never updated IIS so the app pool would stop by itself every time when a try to run website. Even if I start AppPool manually, It stopped on website run.
Solution: update the credentials for the account on IIS or use another account
I
Application's DefaultAppPool (or other custom name) may have stopped for some reason. Make sure it is on. Recycle too.
I have faced this issue recently after Windows 10 update (Dev machine).
I have created a new IIS AppPool and assigned to the website and that fixed the issue.
You should try to remove IIS Express folder at %USERPROFILE%\Documents.
Next important thing is to restart Visual Studio and open it as admin.
Then you can right click your ASP.NET project and go into Properties view. There you can configure web settings for IIS hosting in the Web tab. Try to change IIS settings here and then save with Ctrl+S.
When there is a * next to the web tab because you tried to edit settings but could not save, you need to change to another tab, switch back to Web tab and then save with Ctrl+S. (The Properties view for ASP.NET apps in Visual Studio is still buggy ...)
I am currently using Visual Studio 2015 CE so I don't know whether my solution applies to your problem. Anyways try to remove any folders that got cached by IIS Express hosting and never really got cleaned up afterwards.
So, in my case the only thing that fixed this was setting the ip statically in a new binding protocol, in your case would be something like this:
<site name="SMApplication(4)" id="10">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\DanZe3\Documents\Visual Studio 2013\Projects\SMApplication\SMApplication" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:29790:localhost" />
<binding protocol="http" bindingInformation="*:29790:192.168.1.8" />
</bindings>
</site>
This won't cause any problem in a production environment.
I want to test some subdomain features in an asp.net site. I read just to edit the hosts file and add 127.0.0.1 subdomain.domain.com and that should work.
But mine seems to not. I have flushed the dns, restarted, tried new browsers and still get error 500.
When I normal run the asp.net site from Visual Studio it goes to http://localhost:17365/ . How do I get the IP address for this?
I guess I don't get the whole picture and missing some pieces.
I ran netstat -n and see that the site is running on[::1]:17365 maybe thats why its not working under ipv4?
The solution is very simple.
After you have edit your host files adding a line as:
127.0.0.1 subdomain.domain.com
you run your site, the personal web starts and you get on your browser this
http://localhost:[PortNumber]/ (eg: http://localhost:17365/ )
just change it to
http://subdomain.domain.com:[PortNumber]/ (eg:http://subdomain.domain.com:17365/)
with your hand, type it on the url on your browser, and it will work.
In visual studio when you go to run the site first change in the Website Properties > Use Dynamic PortstoFalse, then set the Port Numberto80, then run it.
It will by default launch http://localhost:80, however then in your browser visit subdomain.domain.com in your browser it will point to your debugging instance of your site (assuming you've still got that 127.0.0.1 subdomain.domain.com in your hosts file).
I just go to Project Properties > Web and under Servers, I select Use Local IIS Web server and set the Project Url to subdomain.domain.com.
Someone has registered "lvh.me" that point to 127.0.0.1
So you can use:
http://lvh.me
http://something.lvh.me
You have to configure your web server also.
Ok, you changed the hosts file. Your system (dns) knows where to go (127.0.0.1) with the host.
But your web server still know nothing about subdomain.domain.com and associates nothing with it.
When you normally start an asp.net site in Visual Studio it uses the Cassini webserver.
I'm not sure if you can configure bindings for Cassini.
My suggestion would be to configure a website or virtual directory in IIS with bindings to subdomain.domain.com, look here on how to do that: Add a binding to a site
Your hosts file should contain this:
127.0.0.1 subdomain.domain.com
The request of subdomain.domain.com will then be redirected to your Local IIS Web server (on port 80), because of the binding configuration IIS knows where to look for your website.
Within the properties of your web project in Visual Studio you can configure to use Local IIS Web server in the Web tab.
I'm not sure that the Visual Studio Development Server can handle bindings to anything other than localhost. I think the only thing you can change is the port number.
You have a couple of options.
1) Install IIS Express (or full-on IIS if you want) and configure Visual Studio to point to the site you have set up in there. You can manually set up your binding to subdomain.domain.com and it's very flexible. Take a look at this answer: Using Custom Domains With IIS Express
2) Install a port forwarder like rinetd (I think this should work if you have the entry in your hosts file). You should be able to map subdomain.domain.com:<some port number> to localhost:17365. Note that rinetd won't detect the domain you're using (just the underlying IP address which is 127.0.0.1), so it's best to use a distinct port for each project you're working on.
Goto applicationhost.config, you can find on windows tray.
Finding application.config of a current running project in IIS
Now find
<webLimits>
......
<sites>
.....
<site name="[YourProjectName]" id="[YourProjectID]">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="[Your Project Path]" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:50569:[Remove localhost from here]" />
</bindings>
</site>
.....
</sites>
......
<webLimits />
Remove localhost from bindingInformation.
Finally, Run VisualStudio as Administrator
I'm using VS 2017 and Webforms (don't say it).
In the Solution (.sln) file (in notepad) I changed the port to 8080. This was found in several properties, including VWDPort, Debug.AspNetCompiler.VirtualPath, Debug.AspNetCompiler.TargetPath, Release.AspNetCompiler.VirtualPath, and Release.AspNetCompiler.TargetPath
In the applicationhost.config file, I added:
<binding protocol="http" bindingInformation="*:8080:subdomain.domain" />
Also done in notepad. Make sure there are no duplicate or old entries anywhere in this file for bindings. After you change the port in Step 1 you may get an auto-generated duplicate entry with old bindings. Also, be sure you editing the correct applicationhost.config file. This file is in a different place depending on your version of VS.
In Powershell, run: "netsh http add urlacl url=http://subdomain.domain:80/ user=everyone"
In your hosts file (mine is in C:\Windows\System32\drivers\etc) add "127.0.0.1 subdomain.domain" to your hosts listing. You'll have to be an administrator (right-click on notepad, run as administrator)
Run VS as Administrator. This will keep the port to 80. If not run as administrator, you'll get a random port number, your .sln file will get auto-edited with this number, and you'll get duplicate bindings in applicationhost.config.
Running as Administrator is irritating, but it's the only way I could get the port to not change. Also, I tried using other ports, such as the one randomly assigned VS, but kept running into 503 errors from IIS.
Using this you could get a list of IP addresses if I add this code it resolves to
127.0.0.1 please confirm if this is what you are looking for otherwise I will remove the answer
foreach (IPAddress address in Dns.GetHostAddresses("localhost"))
{
Console.WriteLine(address.ToString());
}