• 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);
            }
        }
  • 相关阅读:
    扩展性很好的一个分页存储过程
    SQL中列转行
    Server.MapPath() 方法(摘自互联网)
    容易遗忘のSQL
    Linq读取XML
    字节流和字符流
    Java中" "和 ' '
    Spring常用基本注解
    finally和return
    JS 深度clone
  • 原文地址:https://www.cnblogs.com/gaobing/p/5825521.html
Copyright © 2020-2023  润新知