在 Startup 類別的 Configuration(IAppBuilder app) 裡添加程式碼:
app.Map("/signalr", map =>
{
// To enable CORS requests, Install-Package Microsoft.Owin.Cors
// Setup the cors middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(CorsOptions. AllowAll);
var hubConfiguration = new HubConfiguration
{
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
// EnableJSONP = true
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch is already runs under the "/signalr"
// path.
map.RunSignalR( hubConfiguration);
});
// 這裡是新添加的部分
var physicalFileSystem = new PhysicalFileSystem(@"./www");
var options = new FileServerOptions
{
EnableDefaultFiles = true,
FileSystem = physicalFileSystem
};
options.StaticFileOptions. FileSystem = physicalFileSystem;
options.StaticFileOptions. ServeUnknownFileTypes = true;
options. DefaultFilesOptions. DefaultFileNames = new[] { "index.html" };
app.UseFileServer(options);
//
app.UseWelcomePage();
在 [專案名稱]\bin\Debug 裡新增資料夾 www