Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

index.html not showing as default page

I have created an empty Web Application in .NET Core, in wwwroot I have the index.html which is not loading as default page, it loads only when I call it explicitly.

Here is my project.json

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

Here my Startup:

public class Startup
{
    // This method gets called by the runtime. Use this method to add services to the container.
    // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app)
    {
        app.UseStaticFiles();
    }

    // Entry point for the application.
    public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}
like image 368
DAG Avatar asked Mar 03 '16 16:03

DAG


People also ask

Why is my html code not showing up?

Possible Reasons: You might not have saved the changes after writing the code (most likely). Problem with the browser (load it in another browser) Check the extension (just for clarification)

Is index html the default?

Default HomepageThe index. html page is the most common name used for the default page shown on a website if no other page is specified when a visitor requests the site.

Why is index HTML not working?

If you've just placed an index. html or index. php file on your server's document root folder, for example: /public_html/ and you're still not getting it to load these files upon a request to your domain, chances are your server is missing a specific configuration for the "DirectoryIndex Directive".


1 Answers

You have to add

app.UseDefaultFiles();

before app.UseStaticFiles(); in Configure method.

See documentation for more details.

like image 103
Andrey Korneyev Avatar answered Oct 24 '22 02:10

Andrey Korneyev