Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify launchSettings.json in order to point to index.html

I'm largely a newbie to ASP.NET Core. I created a Web API template and setup a controller, then manually created the following directory structure under wwwroot:

wwwroot/
  css/
    site.css
  js/
    site.js
  index.html

When I hit F5, I want to launch index.html in the browser. However, I can't figure out how to do this. Here's my launchSettings.json:

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

When I run the "IIS Express" command in Chrome, I get "No webpage was found for the web address: http://localhost:63123/index.html". Why is this happening?

The full source of my app is available here: https://github.com/jamesqo/Decaf/tree/webapp-2/Decaf.WebApp.

like image 877
James Ko Avatar asked Oct 21 '25 14:10

James Ko


1 Answers

I downloaded your code and changed your launchsettings file to the fully qualified url:

"launchUrl": "http://localhost:63123/index.html",    

I also amended your StartUp.cs adding (app.UseStaticFiles();) and it now seems to work:

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }

    app.UseStaticFiles();

    app.UseMvc();
}

Result on running:

enter image description here

like image 189
SBFrancies Avatar answered Oct 23 '25 04:10

SBFrancies



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!