zoukankan      html  css  js  c++  java
  • OWIN启动项的检测

    OWIN启动项的检测

    通过以下方法设置启动项:

    1. 命名约定 Katana在命名空间内查找StartUp类

    2. OwinStartup Attribute

       [assembly: OwinStartup(typeof(StartupDemo.TestStartup))]
      
    3. 在Configuration文件中设置appSetting

       <appSettings>  
         <add key="owin:appStartup" value="StartupDemo.ProductionStartup" />
       </appSettings>
      

      显示指定startup class和assembly

       <appSettings>  
         <add key="owin:appStartup" value="ProductionConfiguration" />       
       </appSettings>
      

      在配置文件中指定一个友好的startup class名称

       <appSettings>  
         <add key="owin:appStartup" value="ProductionConfiguration" />       
       </appSettings>
      

      使用了上述的配置,必须使用OwinStartup特性指定一个同样的名称

      	[assembly: OwinStartup("ProductionConfiguration", typeof(StartupDemo.ProductionStartup2))]
       
       namespace StartupDemo
       {
           public class ProductionStartup
           {
               public void Configuration(IAppBuilder app)
               {
                   app.Run(context =>
                   {
                       string t = DateTime.Now.Millisecond.ToString();
                       return context.Response.WriteAsync(t + " Production OWIN App");
                   });
               }
           }
           public class ProductionStartup2
           {
               public void Configuration(IAppBuilder app)
               {
                   app.Run(context =>
                   {
                       string t = DateTime.Now.Millisecond.ToString();
                       return context.Response.WriteAsync(t + " 2nd Production OWIN App");
                   });
               }
           }
       }
      
    4. 设置appSetting的owin:AutomaticAppStartup值为false禁用OWIN启动发现

    在IIS中启动

    	using System;
    	using System.Threading.Tasks;
    	using Microsoft.Owin;
    	using Owin;
    	
    	[assembly: OwinStartup(typeof(StartupDemo.ProductionStartup))]
    	
    	namespace StartupDemo
    	{
    	    public class ProductionStartup
    	    {
    	        public void Configuration(IAppBuilder app)
    	        {
    	            app.Run(context =>
    	            {
    	                string t = DateTime.Now.Millisecond.ToString();
    	                return context.Response.WriteAsync(t + " Production OWIN App");
    	            });
    	        }
    	    }
    	}
    

    在OwinHost.exe中启动

  • 相关阅读:
    [转]手工实现RTTI
    小楫轻舟
    百年孤独
    The power of now
    [转帖]Android平台下OpenGL初步
    设计模式六大原则(5):迪米特法则
    设计模式六大原则(4):接口隔离原则
    设计模式六大原则(3):依赖倒置原则
    设计模式六大原则(1):单一职责原则
    设计模式六大原则(2):里氏替换原则
  • 原文地址:https://www.cnblogs.com/goodlucklzq/p/4499986.html
Copyright © 2011-2022 走看看