Bur*_*jua 25 routing asp.net-web-api single-page-application owin
应该是一个简单的问题,只是找不到答案.
我有一个带有web api的SPA(AngularJS),它是由Owin自己托管的.我使用Nancy来提供页面,但我想摆脱Nancy并使用Index.html作为我的单页.
我在这里看到了这个问题:如何将除Web API以外的所有内容路由到/index.html
我不能使用已接受的答案,因为我没有MVC和HomeController,在更新的问题中建议的方式也不起作用,我得到 No HTTP resource was found that matches the request URI 'http://admin.localhost:33333/'.
No route providing a controller name was found to match request URI 'http://admin.localhost:33333/'
小智 38
将Index.html移动到项目的根目录.然后install-package Microsoft.Owin.StaticFiles
在Package Manager Console中添加以下代码:
public class Startup
{
public void Configuration(IAppBuilder app)
{
const string rootFolder = ".";
var fileSystem=new PhysicalFileSystem(rootFolder);
var options = new FileServerOptions
{
EnableDefaultFiles = true,
FileSystem = fileSystem
};
app.UseFileServer(options);
}
}
Run Code Online (Sandbox Code Playgroud)
这将默认提供您的Index.html.
您可以查看Scott Allen的博客以获取更多信息:
归档时间: |
|
查看次数: |
11375 次 |
最近记录: |