【发布时间】:2014-07-28 21:08:31
【问题描述】:
我正在尝试将我的内容保存在非默认位置(例如bower_components 或/packages/../tools)。作为实验的一部分,我正在尝试设置一个 asp.net mvc 5 应用程序,在该应用程序中,点击某个路由可以让我浏览 undersorejs 包目录中的文件。
我有以下 nuget 包(除了默认的)
Install-Package underscore.js
Install-Package Microsoft.Owin.StaticFiles
Install-Package Microsoft.Owin.Host.SystemWeb
这就是我在 OWIN 启动课程中的内容
var fileSystem = new PhysicalFileSystem(
HttpContext.Current.Server.MapPath("~")+"/../packages/underscore.js.1.6.0"
);
var options = new FileServerOptions {EnableDirectoryBrowsing = true, FileSystem = fileSystem};
app.MapWhen(ctx =>
ctx.Request.Uri.AbsolutePath.StartsWith("/__underscore"),
ab => ab.UseFileServer(options)
);
根据我的理解和之前的实验,这非常简单 - 当请求以 /__underscore use the simple static file server 开头时。但是,当我转到 /__underscore 时,我收到 404 错误。
但是,放置断点我可以看到 UseFileServer lambda 在启动时执行一次,然后不再执行,而谓词 lambda 在每个请求上都被调用(并返回正确的值)。
我错过了什么?
【问题讨论】:
-
应用程序是如何托管的?
-
@haim770 iis express。目前只是默认的 MVC asp.net web 项目和 f5
标签: asp.net owin fileserver