Owin中间件导致服务器返回404错误

5

我有一个OWIN中间件,它在我的开发机(Win7)上的IIS7上工作正常。但是,当部署到2008服务器时,页面返回404错误。

我像这样连接中间件

public static class AppBuilderExtensions
{
    public static void InitTemplateStore(this IAppBuilder app, string templatePath, string fileMask)
    {
        TemplateStoreMiddleware.Init(templatePath, fileMask);
        app.Map("/templates", subApp => subApp.Use<TemplateStoreMiddleware>());
    }
}

使用中间件的代码可以在这里找到:https://github.com/AndersMalmgren/Knockout.Bootstrap.Demo。该网站作为虚拟应用程序托管在IIS默认网站下。编辑:我是否需要添加默认角色之外的任何角色?IIS试图使用StaticFile处理程序,这当然是错误的,为什么会发生这种情况?
Module  IIS Web Core
Notification    MapRequestHandler
Handler StaticFile
Error Code  0x80070002
Requested URL   http://localhost:80/knockout.bootstrap.demo/templates?root=shared
Physical Path   C:\inetpub\knockout.bootstrap.demo\templates
Logon Method    Anonymous
Logon User  Anonymous

我有一个与StaticFiles OWIN模块类似的问题:https://gist.github.com/koistya/9951731 - Konstantin Tarkus
1个回答

10
OWIN中间件无法在IIS集成管线中正常工作的一些常见原因。
  1. 检查您的项目中是否安装了Microsoft.Owin.Host.SystemWeb nuget包,并且它在应用程序的bin文件夹中。
  2. 您的应用程序池是否是v4.0集成模式(很可能是这个?)
这篇文章可能会有所帮助。另外,这个问题我认为与您的问题类似。

两者都是正确的,将检查链接。它可以在我的win7 IIS7上开箱即用,并且使用默认设置(我创建一个指向发布文件夹的应用程序),这非常奇怪。 - Anders
我已验证Owin启动正在执行,因此我的中间件已注册,但仍然无效。 - Anders
2
这个问题有什么修复方法吗? - Blaise
我的库的用户报告说他遇到了同样的问题,而这个方法 app.UseStageMarker(PipelineStage.MapHandler) 帮助了他。我会调查为什么会出现这种情况。 - Anders
哦,你也救了我的一天。 - Carlo Luther

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接