为什么网站默认不默认为index.html?

Sco*_*rod 1 f# elm .net-core asp.net-core

我无法输入域名来观察登录页面:

http://some_url.com
Run Code Online (Sandbox Code Playgroud)

错误:

找不到文件'E:\ index.html'.

但是,以下工作:

http://some_url.com/index.html

仅供参考:本网站由Elm,Giraffe和.Net Core构建.

Cha*_*ert 6

如果您正在运行Giraffe,那么您正在运行F#,这意味着您很有可能正在使用IApplicationBuilder配置服务器.您应该能够调用UseDefaultFiles,然后UseStaticFiles使用index.html作为默认文档.

let configureApp (app : IApplicationBuilder) =
    app.UseGiraffeErrorHandler errorHandler
    app.UseDefaultFiles() |> ignore
    app.UseStaticFiles() |> ignore
    app.UseGiraffe webApp
Run Code Online (Sandbox Code Playgroud)

服务静态文件:

UseDefaultFiles必须先调用才能UseStaticFiles提供默认文件.UseDefaultFiles是一个实际上不提供文件的URL重写器.您必须启用静态文件中间件(UseStaticFiles)来提供该文件.