How to set default static web page for Katana/Owin self hosted app?

前端 未结 5 1757
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-29 07:34

I\'ve set up a web site using an Owin self hosted console app. I\'m serving static files with no problem, the \'root\' of the static part of the site works properly, and th

5条回答
  •  难免孤独
    2020-12-29 07:39

    I do it this way:

    var physicalFileSystem = new PhysicalFileSystem(webPath);
    var options = new FileServerOptions
                              {
                                  EnableDefaultFiles = true,
                                  FileSystem = physicalFileSystem
                              };
            options.StaticFileOptions.FileSystem = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = new[] { "index.html" };
            appBuilder.UseFileServer(options);
    

提交回复
热议问题