可以将OWIN Nancy与Web Forms一起使用吗?

时间:2014-01-17 10:20:22

标签: asp.net nancy owin

我像这样定义Nancy类:

public class DefNancy : NancyModule
{
    public DefNancy() : base("/nancy") {
        Get["/"] = _ => {
            var model = new { title = "Hello world" };
            return View["home", model];
        };
    }
}

在OWIN Startup课程中:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        var hubConfiguration = new HubConfiguration();
        hubConfiguration.EnableDetailedErrors = true;
        app.MapSignalR(hubConfiguration);

        config = new HttpConfiguration();
        config.MapHttpAttributeRoutes();
        config.Routes.MapHttpRoute("def","api/{Controller}");
        config.Formatters.Remove(config.Formatters.XmlFormatter); 
        app.UseWebApi(config);

        app.UseNancy();
    }
}

但现在我的* .aspx和另一个页面返回404错误。

1 个答案:

答案 0 :(得分:5)

使用此:

app.UseNancy(options =>
    options.PerformPassThrough = context =>
        context.Response.StatusCode == HttpStatusCode.NotFound);