Using asp.net core 2.0 with Visual Studio Community 2017 for Mac
Created a brand new asp.net core web app project using the provided template
Click run project
Project builds successfully
Browser opens and shows message: Safari Cannot Open The Page - Safari cannot open the page localhost:5001 because the server unexpectedly dropped the connection
In Visual Studio Community IDE the Program.cs file loads with BuildWebHost(args).Run(); highlighted
Click continue button in IDE brings up a Program Report for dot net - dot net quit unexpectedly
Note that the asp.net core empty template runs without an issue
If I run dotnet build and then dotnet run from the command line I get a lot more detail - the error I see then is that
http://localhost:5001 is already in use.
So I added UseUrls("http://localhost:5002/") to Program.cs
Now I can execute dotnet build and dotnet run from the command line and then in my web browser go to
http://localhost:5002 to see the web app
NOTE that Visual Studio Community still tries to open the web app at
http://localhost:5001 when I run the web app from within Visual Studio
Here is how you can set the port for running locally
Under the properties folder is a file launchSettings.json
In that file is the applicationUrl value for the Development environment -
http://localhost:5001
You can change that to what you need for your environment
Close the project and reopen it - Now Visual Studio should have your web browser use the port you specified when loading the page when you run the project
Open Program file and add .UseUrls("http://localhost:5002")
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("http://localhost:5002")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
With regards, Angelina Jolie
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Thanks for sharing the solution for the issues while developing on Mac. I would suggest you mark your reply as answer, and then others who run into the same issue would find the solution easily.
Regards,
Tony
Mark The Reply As Answer If It Resolves Your Issue.
Member
1 Points
7 Posts
default asp.net core web app template fails to run
Oct 22, 2017 12:33 PM|phillips1021|LINK
Using asp.net core 2.0 with Visual Studio Community 2017 for Mac
Created a brand new asp.net core web app project using the provided template
Click run project
Project builds successfully
Browser opens and shows message: Safari Cannot Open The Page - Safari cannot open the page localhost:5001 because the server unexpectedly dropped the connection
In Visual Studio Community IDE the Program.cs file loads with BuildWebHost(args).Run(); highlighted
Click continue button in IDE brings up a Program Report for dot net - dot net quit unexpectedly
Note that the asp.net core empty template runs without an issue
Member
1 Points
7 Posts
Re: default asp.net core web app template fails to run
Oct 22, 2017 12:54 PM|phillips1021|LINK
Think I found the problem
If I run dotnet build and then dotnet run from the command line I get a lot more detail - the error I see then is that http://localhost:5001 is already in use.
So I added UseUrls("http://localhost:5002/") to Program.cs
Now I can execute dotnet build and dotnet run from the command line and then in my web browser go to http://localhost:5002 to see the web app
NOTE that Visual Studio Community still tries to open the web app at http://localhost:5001 when I run the web app from within Visual Studio
Member
1 Points
7 Posts
Re: default asp.net core web app template fails to run
Oct 22, 2017 01:06 PM|phillips1021|LINK
Here is how you can set the port for running locally
Under the properties folder is a file launchSettings.json
In that file is the applicationUrl value for the Development environment - http://localhost:5001
You can change that to what you need for your environment
Close the project and reopen it - Now Visual Studio should have your web browser use the port you specified when loading the page when you run the project
Contributor
5200 Points
2307 Posts
Re: default asp.net core web app template fails to run
Oct 23, 2017 09:53 AM|AngelinaJolie|LINK
Hi phillips,
Good Day!
Yes, and I tested a working example on local :
first step:
Open launchSettings.json and change http://localhost:5000 port to http://localhost:5002 port
{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:36133/", "sslPort": 0 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, "ContosoUniversity": { "commandName": "Project", "launchBrowser": true, "launchUrl": "http://localhost:5002", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } }
Second step:
Open Program file and add .UseUrls("http://localhost:5002")
public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseUrls("http://localhost:5002") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); }
With regards, Angelina Jolie
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
198 Points
158 Posts
Re: default asp.net core web app template fails to run
Oct 30, 2017 07:01 AM|TonyHelp|LINK
Hi phillips,
Thanks for sharing the solution for the issues while developing on Mac. I would suggest you mark your reply as answer, and then others who run into the same issue would find the solution easily.
Regards,
Tony