我像这样定义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错误。
答案 0 :(得分:5)
使用此:
app.UseNancy(options =>
options.PerformPassThrough = context =>
context.Response.StatusCode == HttpStatusCode.NotFound);