-
Notifications
You must be signed in to change notification settings - Fork 0
/
OwinStartUp.cs
43 lines (35 loc) · 1.39 KB
/
OwinStartUp.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Owin;
using Microsoft.Owin.StaticFiles;
using Microsoft.Owin.FileSystems;
using Microsoft.Owin.Extensions;
using System.Web.Http;
namespace WebApiHost
{
public class OwinStartUp
{
public void Configuration(IAppBuilder appBuilder)
{
//hosting static files i.e. angular
//install-package Microsoft.Owin.SelfHost
//install-package Microsoft.Owin.StaticFiles
var options = new FileServerOptions();
options.EnableDirectoryBrowsing = true;
options.FileSystem = new PhysicalFileSystem("./app");
options.StaticFileOptions.ServeUnknownFileTypes = true;
appBuilder.UseFileServer(options);
// Configure Web API for self-host.
//Install-Package Microsoft.AspNet.WebApi.OwinSelfHost
HttpConfiguration config = new HttpConfiguration();
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.MapHttpAttributeRoutes();
appBuilder.UseWebApi(config);
//Install-Package Microsoft.Owin.Cors
appBuilder.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
}
}
}