zoukankan      html  css  js  c++  java
  • NancyFx中使用自带的IOC容器

        /// <summary>
        /// Cors扩展
        /// </summary>
        public static class IPipelinesExtensions
        {
            /// <summary>
            /// CORS Enable
            /// </summary>
            /// <param name="pipelines">pipelines</param>
            public static void UserCors(this IPipelines pipelines)
            {
    
                pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) =>
                {
                    ctx.Response.WithHeader("Access-Control-Allow-Origin", "*")
                                    .WithHeader("Access-Control-Allow-Methods", "POST,GET")
                                    .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type");
    
                });
            }
        }
    
    
        /// <summary>
        /// Nancyfx Ioc
        /// </summary>
        public class MyBootstrapper : DefaultNancyBootstrapper
        {
            protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
            {
                // pipelines.UserCors();
                base.ApplicationStartup(container, pipelines);
    
            }
    
            protected override void ConfigureApplicationContainer(TinyIoCContainer container)
            {
                container.Register<ISys_User, Sys_User>
                base.ConfigureApplicationContainer(container);
            }
        }
  • 相关阅读:
    django rest_framework中将json输出字符强制为utf-8编码
    Java
    Java
    Oracle
    IDEA
    Ubuntu
    Ubuntu
    Ubuntu
    Ubuntu
    Oracle
  • 原文地址:https://www.cnblogs.com/gaobing/p/5825521.html
Copyright © 2011-2022 走看看