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

打玻璃
1,591
Reputation points
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
{count} votes
asp.net core 5.0 razpr page yes I tried but not work.
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.
There is no
index.html
in the wwwroot root folder.I use `page "index.html" in the Index.cshtml So I can use index.html to Index
http://www.xxxxx.com/index.html is http://www.xxx.com/Index
According to your description, I couldn't understand clearly. Do you mean your wants to modify your razor page's default page to index.cshtml ? Or you have index.html and index.cshtml? If possible, could you please share your project directory makeup and startup.cs route config related codes?
I do not want to modify the razor pges's default page.
As you know the default page is
Index
,but I can change the Index toindex.html
right?but then I can not use the default page.
before change the default page url is'
http://xxxx.com/Index
I can open it 'http://www.xxxx.com' it will auto open the page 'Index
but after change the url of the
Index
toindex.html
@page "/index.html" I can not open the page use the url
http://www.xxxx.com` there will be an 404 error.Sign in to comment
1 answer
Sort by: Most helpful
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
There still a 404 error
Sign in to comment