29 lines
811 B
Plaintext
Executable File
29 lines
811 B
Plaintext
Executable File
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.Http;
|
|
using System.Web.Http.Cors;
|
|
|
|
|
|
namespace GuangFu.StringTracing
|
|
{
|
|
public static class WebApiConfig
|
|
{
|
|
public static void Register(HttpConfiguration config)
|
|
{
|
|
// 启用CORS(跨域资源共享)
|
|
// 方法1:全局启用CORS(允许所有来源)
|
|
var cors = new EnableCorsAttribute("*", "*", "*");
|
|
config.EnableCors(cors);
|
|
|
|
config.Routes.MapHttpRoute(
|
|
name: "DefaultApi",
|
|
routeTemplate: "api/{controller}/{action}/{id}",
|
|
defaults: new { id = RouteParameter.Optional }
|
|
);
|
|
|
|
log4net.Config.XmlConfigurator.Configure();
|
|
}
|
|
}
|
|
}
|