如何设置默认的静态网页的武士刀/ Owin自托管应用程序? [英] How to set default static web page for Katana/Owin self hosted app?

查看:263
本文介绍了如何设置默认的静态网页的武士刀/ Owin自托管应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了使用Owin自托管控制台应用程序的Web站点。我服,没有问题静态文件,该网站的静态部分的根正常工作,和Web API路线做工精细也。

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 the web API routes work fine also.

如果我浏览到:

http://localhost/index.html

这presents一切都像我期望的那样。但我还没有想出如何设置,使浏览到:

it presents everything like I expect. But I have not figured out how to set it so that browsing to:

http://localhost

presents的index.html(作为默认视图)。这一个IIS风格的站点下很好用。我该如何使之与Owin自主机工作?

presents index.html (as the default view). This Just Works under an IIS-style site. How do I make it work with Owin self host?

推荐答案

我做这种方式:

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);

这篇关于如何设置默认的静态网页的武士刀/ Owin自托管应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆