12
votes

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.

2

2 Answers

17
votes

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"
      }
    }
  }
}
7
votes

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.