How to set up URL of ASP.NET Core Web Application in Visual Studio 2015

18,018

Solution 1

In the properties folder you have the file launchSettings.json, where you can set some settings of your application.

You will find something like this :

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:52023/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "index",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "YOUR_PROJECT_NAMESPACE": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:52023/index",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Solution 2

You can define it where you are writing server related stuff like

var host = new WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseUrls("http://localhost:29492/HelloASPNETCore")
    .UseIISIntegration()
    .UseStartup<Startup>()
    .Build();

If you are using visual studio then you can do it by modifying properties/launchSettings.json file with the correct launchUrl like this:

"launchUrl": "http://localhost:29492/HelloASPNETCore"

For more details follow this article

You have to setup the routing to support.

Share:
18,018
Paul Ma
Author by

Paul Ma

Updated on June 08, 2022

Comments

  • Paul Ma
    Paul Ma almost 2 years

    I've create a ASP.NET Core Web Application in Visual Studio 2015 named "HelloASPNETCore", with the default template which has one controller "Home" and several actions "Index", "Contact".....etc; now I want to launch it on IIS Express with the root URL as

    http://localhost:29492/HelloASPNETCore
    

    but the default URL that Visual Studio set up to me is

    http://localhost:29492
    

    In the classic ASP.NET MVC Web Application Project I just specified the Project URL in the Project Properties and it works, but it's not work on the ASP.NET Core Web Application Project. I input the URL http://localhost:29492/Home/Index on browser and got the correct content respond, but http://localhost:29492/HelloASPNETCore/Home/Index gave me the empty content, without any error information.

  • Paul Ma
    Paul Ma almost 8 years
    I've found the launchSettings.json and modified it as
  • Paul Ma
    Paul Ma almost 8 years
    Sorry I've not finished my previous comment. I've modified the launchSettings.json then re-launch but still got empty content from localhost:29492/HelloASPNETCore. Due to the content length limitation I can't post my launchSettings.json content here.
  • AdrienTorris
    AdrienTorris almost 8 years
    If you have empty content it's note a launch configuration problem. You may have a routing problem, or a controller's action rendering empty content.
  • Paul Ma
    Paul Ma almost 8 years
    In addition to modify launchSettings.json, do I have to modify the routes.MapRoute code on the Startup.cs as well?