• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Cors.EnableCorsAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.Http.Cors.EnableCorsAttribute的典型用法代码示例。如果您正苦于以下问题:C# EnableCorsAttribute类的具体用法?C# EnableCorsAttribute怎么用?C# EnableCorsAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EnableCorsAttribute类属于System.Web.Http.Cors命名空间,在下文中一共展示了EnableCorsAttribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Register

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            //clear default formatters 
            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());

            //set formatters only json 
            var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
            //optional: set serializer settings here
            config.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator(jsonFormatter));
                        
            //jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        }
开发者ID:alexaung,项目名称:OBTS,代码行数:27,代码来源:WebApiConfig.cs


示例2: Register

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            //Unity
            var container = new UnityContainer();
            container.RegisterType<IUnitOfWork, UnitOfWork>(new HierarchicalLifetimeManager());
            container.RegisterType<IGenericRepository<Farmacia>, GenericRepository<Farmacia>>(new HierarchicalLifetimeManager());
            config.DependencyResolver = new UnityResolver(container);

            //Formatters
            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
            //GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
            //config.Formatters.Insert(0, new System.Net.Http.Formatting.JsonMediaTypeFormatter());

            // Web API routes
            config.MapHttpAttributeRoutes();
            //config.EnableCors();
            var cors = new EnableCorsAttribute("http://localhost:28285", "*", "*");
            config.EnableCors(cors);

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
开发者ID:RubenGomes10,项目名称:Farma,代码行数:30,代码来源:WebApiConfig.cs


示例3: Register

        public static void Register(HttpConfiguration config)
        {
            var corsConfig = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(corsConfig);
            // Конфигурация и службы Web API
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
            config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.None;
            config.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
            
            // Отключение xml вывода 
            var formatters = GlobalConfiguration.Configuration.Formatters;
            formatters.Remove(formatters.XmlFormatter);
            
            // Настройка Web API для использования только проверки подлинности посредством маркера-носителя.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Маршруты Web API
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
开发者ID:pro2s,项目名称:FoodApp,代码行数:27,代码来源:WebApiConfig.cs


示例4: Register

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Enable cross origin requests to API
            var cors = new EnableCorsAttribute(
                origins: "*",
                headers: "*",
                methods: "*"
            );
            config.EnableCors(cors);

            //var cors = new EnableCorsAttribute("*", "*", "*");
            //config.EnableCors(cors);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            // Remove XML format in order to return JSON
            var appXmlType =
                config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault
                                            (t => t.MediaType == "application/xml");
            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
        }
开发者ID:kds-snyder,项目名称:17-LargeBank-API,代码行数:29,代码来源:WebApiConfig.cs


示例5: Register

        public static void Register(HttpConfiguration config)
        {
            var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);

            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            var json = config.Formatters.JsonFormatter;
            json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            json.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
        }
开发者ID:mzaatar,项目名称:HO2,代码行数:25,代码来源:WebApiConfig.cs


示例6: Register

        public static void Register(HttpConfiguration config)
        {
            var corsAttr = new EnableCorsAttribute(
                ConfigurationManager.AppSettings["EnableCords.Origins"],
                ConfigurationManager.AppSettings["EnableCords.Headers"],
                ConfigurationManager.AppSettings["EnableCords.Methods"],
                ConfigurationManager.AppSettings["EnableCords.ExposedHeaders"]);
            config.EnableCors(corsAttr);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            config.Routes.MapHttpRoute(
                  name: "DefaultApiAction",
                  routeTemplate: "api/{controller}/{parentId}/{action}/{id}",
                  defaults: new { id = RouteParameter.Optional }
            );

            config.MessageHandlers.Add(new TokenValidationHandler(config.DependencyResolver.GetService(typeof(AuthenticationService)) as AuthenticationService));

            config.Formatters.Add(new JsonMediaTypeFormatter());
            config.Formatters.JsonFormatter.Indent = true;
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
        }
开发者ID:leocosta,项目名称:TicketStore,代码行数:31,代码来源:WebApiConfig.cs


示例7: Register

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            var originDomains = System.Configuration.ConfigurationManager.AppSettings["OriginDomains"];
            var cors = new EnableCorsAttribute(originDomains, "*", "*") { SupportsCredentials = true };

            config.EnableCors(cors);

            var formatters = GlobalConfiguration.Configuration.Formatters;
            var jsonFormatter = formatters.JsonFormatter;
            var settings = jsonFormatter.SerializerSettings;
            settings.Formatting = Formatting.Indented;
            settings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            var authorisedRoles = System.Configuration.ConfigurationManager.AppSettings["AuthorisedRoles"];
            config.Filters.Add(new AuthorizeAttribute
            {
                Roles = authorisedRoles
            });

            config.Filters.Add(new ExceptionHandlingAttribute());

            // Web API routes
            config.MapHttpAttributeRoutes();

            //config.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    routeTemplate: "api/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);
        }
开发者ID:kejto,项目名称:DataStore-BDD,代码行数:31,代码来源:WebApiConfig.cs


示例8: Register

        public static void Register(HttpConfiguration config)
        {
            var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);

            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            config.Formatters.Remove(config.Formatters.XmlFormatter);
            var formatters = config.Formatters;
            var jsonFormatter = formatters.JsonFormatter;
            var settings = jsonFormatter.SerializerSettings;
            settings.Formatting = Newtonsoft.Json.Formatting.Indented;
            //settings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
            //var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
            //json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
开发者ID:michaelquinn5280,项目名称:Portfolio,代码行数:26,代码来源:WebApiConfig.cs


示例9: Register

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                "DefaultApi",
                "api/{controller}/{id}",
                new { id = RouteParameter.Optional }
               );

            config.Filters.Add(new InvalidModelStateAttribute());

            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

            var cors = new EnableCorsAttribute(
                origins: "*",
                headers: "*",
                methods: "*");
            config.EnableCors(cors);
        }
开发者ID:kateEvstratenko,项目名称:Bank,代码行数:26,代码来源:WebApiConfig.cs


示例10: Register

        public static void Register(HttpConfiguration config)
        {
            //Auth filter - See configuration in web.config
            config.Filters.Add(new SeranetAuthAttribute());

            // set webapi JSON formatter
            config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
            var json = config.Formatters.JsonFormatter;
            json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            //enable cross domain requests
            var corsAttr = new EnableCorsAttribute("*", "*", "*");
            corsAttr.SupportsCredentials = true;
            config.EnableCors(corsAttr);



            // Web API routes
            config.MapHttpAttributeRoutes();

            config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/bin/Seranet.Api.xml")));

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
开发者ID:hashinisenaratne,项目名称:seranet.api,代码行数:29,代码来源:WebApiConfig.cs


示例11: Register

        public static void Register(HttpConfiguration config)
        {
            var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "Accounts Collection",
                routeTemplate: "accountmanagement/accounts",
                defaults: new { controller = "Accounts", action = "Index" }
            );

            config.Routes.MapHttpRoute(
                name: "Individual Account",
                routeTemplate: "accountmanagement/accounts/{accountId}",
                defaults: new { controller = "Accounts", action = "Account" }
            );

            config.Routes.MapHttpRoute(
               name: "Account Followers",
               routeTemplate: "accountmanagement/accounts/{accountId}/followers",
               defaults: new { controller = "Followers", action = "Index" }
            );
        }
开发者ID:elbandit,项目名称:PPPDDD,代码行数:25,代码来源:WebApiConfig.cs


示例12: Register

        public static void Register(HttpConfiguration config)
        {

            //Enable others ports for any method any header any 
            var rules = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(rules);

            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            //Set API to Get JSON not XML.

            var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);

            //This is to call the function below.
            CreateMaps();
        }
开发者ID:hfakhrulddin,项目名称:15-Kanban-API,代码行数:26,代码来源:WebApiConfig.cs


示例13: Register

        public static void Register(HttpConfiguration config)
        {
            //Enable CORS
            //http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api
            var cors = new EnableCorsAttribute(ConfigurationManager.AppSettings["CORSServer"] ?? "*", "*", "*");
            config.EnableCors();

            // Web API configuration and services
            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
            //config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/plain"));

            //attaching the handlers
            config.MessageHandlers.Add(new RequestFormatHandler());

            // Web API routes
            config.MapHttpAttributeRoutes();

            /*
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
             */
        }
开发者ID:geoyogesh,项目名称:GISCommunity,代码行数:25,代码来源:WebApiConfig.cs


示例14: Register

        public static void Register(HttpConfiguration config)
        {
            // Force load of all Controllers:
            if (Current.WebApiCORSDomains != null)
            {

                var items = Current.WebApiCORSDomains.Split(',');
                var corsAttr = new EnableCorsAttribute(Current.WebApiCORSDomains, "*", "*") {SupportsCredentials = true};
                Current.Log.Add("WebApi REST       : {0} CORS domains allowed.".format(items.Length), Message.EContentType.Info);

                config.EnableCors(corsAttr);
            }

            config.Services.Add(typeof(IExceptionLogger), new GlobalErrorHandler());

            config.SuppressHostPrincipal(); //Isolates WebApi Auth form Host (IIS) Auth

            config.Filters.Add(new NyanAuthenticationFilter());

            config.MapHttpAttributeRoutes(new CustomDirectRouteProvider());

            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());
            config.Formatters.Add(new XmlMediaTypeFormatter());
            config.Formatters.Add(new CsvMediaTypeFormatter());

            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
            //config.Formatters.Add(new CsvMediaTypeFormatter());

            Current.Log.Add("WebApi REST       : Routes registered.", Message.EContentType.Info);
        }
开发者ID:bucknellu,项目名称:Nyan,代码行数:31,代码来源:Initialization.cs


示例15: Register

        public static void Register(HttpConfiguration config)
        {

            var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);
            

            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "ApiWithActionName",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);

            var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        }
开发者ID:GameContester,项目名称:GameContester2.0,代码行数:30,代码来源:WebApiConfig.cs


示例16: Register

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            //Enable CORS
            //var cors = new EnableCorsAttribute("http://localhost/MonfuSportsStore", "*", "*");
            var cors = new EnableCorsAttribute("http://localhost", "*", "*");
            config.EnableCors(cors);

            //return JSON
            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            var jsonFormatter = config.Formatters.OfType<JsonMediaTypeFormatter>().First();
            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
        }
开发者ID:jmonfu,项目名称:SportsStore,代码行数:27,代码来源:WebApiConfig.cs


示例17: Register

        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "Guess",
                routeTemplate: "api/games/{id}/guess",
                defaults: new
                {
                    controller = "Guess",
                }
            );

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional}
            );

            var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);
        }
开发者ID:krumov,项目名称:telerik,代码行数:28,代码来源:WebApiConfig.cs


示例18: Register

        public static void Register(HttpConfiguration config)
        {
            var cors = new EnableCorsAttribute("*", "*", "GET, POST, PUT, DELETE, OPTIONS", "Signature");
            config.EnableCors();

            // Web API 配置和服务
            config.Formatters.Clear();
            var jsonFormatter = new JsonMediaTypeFormatter();
            // Convert all dates to UTC type
            jsonFormatter.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc;
            // Convert all dates to Microsoft type("\/Date(ticks)\/ ")
            //jsonFormatter.SerializerSettings.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.MicrosoftDateFormat;
            jsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
            jsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All;
            jsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            config.Formatters.Add(jsonFormatter);
            //config.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator(jsonFormatter));

            // Web API 路由
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
开发者ID:vivlong,项目名称:WebApiDemo,代码行数:27,代码来源:WebApiConfig.cs


示例19: Register

    public static void Register(HttpConfiguration config)
    {
      // Stop IIS/Asp.Net breaking our routes
      // taken from here:
      // http://www.grumpydev.com/2013/09/17/403-14-error-when-trying-to-access-a-webapi-route/
      // TLDR; if IIS sees a url match a project folder name, all routes will be ignored
      // this setting will prevent that
      RouteTable.Routes.RouteExistingFiles = true;

      // enable Cross-Origin Resource Sharing (CORS)
      var cors = new EnableCorsAttribute("*", "*", "*");
      config.EnableCors(cors);

      // Define routes
      config.Routes.MapHttpRoute(
          name: DEFAULT_ROUTE_NAME,
          // {controller} will match a convention name 
          // (i.e. http get to http://url/demo will invoke DemoController.get... method without an id)
          routeTemplate: "api/{controller}/{id}",
          defaults: new { id = RouteParameter.Optional }
      );
      config.EnableSystemDiagnosticsTracing();

      // Register message handlers
      config.MessageHandlers.Add(new SSLHandler());

      // Register global authentication/authorization filters
      config.Filters.Add(new AuthFilter(AuthFilter.AuthTypes.BEARER, "USER"));
    }
开发者ID:aspirinonfire,项目名称:goalcoach,代码行数:29,代码来源:WebApiConfig.cs


示例20: BuildHttpConfiguration

        private static HttpConfiguration BuildHttpConfiguration()
        {
            var configuration = new HttpConfiguration();

            // configure JSON serialization
            var serializerSettings = configuration.Formatters.JsonFormatter.SerializerSettings;
            serializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
            serializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Unspecified;
            #if DEBUG
            serializerSettings.Formatting = Formatting.Indented;
            #endif
            serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            serializerSettings.Converters.Add(new StringEnumConverter());

            //	enable cors since web server is different port than api server
            var cors = new EnableCorsAttribute("*", "*", "*");
            configuration.EnableCors(cors);

            //	use attribute routing
            configuration.MapHttpAttributeRoutes();

            //	custom factory for web api controllers
            configuration.Services.Replace(typeof(IHttpControllerActivator), new WindsorHttpControllerActivator());

            // Global Exception Logger (log exceptions to NLog)
            configuration.Services.Add(typeof(IExceptionLogger), new NLogExceptionLogger());

            return configuration;
        }
开发者ID:jasonlodice,项目名称:benefitdemo,代码行数:29,代码来源:Startup.cs



注:本文中的System.Web.Http.Cors.EnableCorsAttribute类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Description.ApiDescription类代码示例发布时间:2022-05-26
下一篇:
C# Controllers.HttpRequestContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap