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中启动

你可能感兴趣的:(in)