question

6666666 avatar image
0 Votes"
6666666 asked 6666666 commented

How to add default page to asp.net core web in linux ?

I am using asp.net core web and linux.
the nginx.conf I add index index.html but it not work.

in razorpages I change the index to index.html
and I want to If one open the url can open the index.html.

http://www.xxxx.com

but now I have to enter the index.html

http://www.xxx.com/index.html

or there will be an 404 error

dotnet-aspnet-core-razor
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you please tell me the version of your asp.net core? Do you use asp.net core MVC, web api or Razor page? Besides, I suggest you could try to add below codes into your startup.cs Configure method. Codes like this app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List<string> { "index.html" } }); app.UseStaticFiles();

0 Votes 0 ·

asp.net core 5.0 razpr page yes I tried but not work.

0 Votes 0 ·

I suggest you could make sure you have the index.html page inside the wwwroot root folder. Besides, I suggest you could share your stratup.cs codes to let me know if you have some other settings.

0 Votes 0 ·
Show more comments

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered 6666666 commented

As you want a static file to be the default, you need to config the default file handler. You want to configure default documents. See docs


[1]: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-5.0

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

There still a 404 error

0 Votes 0 ·