title: ASP.NET MVC OWIN and SignalR - two Startup.cs files
body: <p>I have a problem with my project.</p>
  
  <p>I use ASP.NET MVC with ASP.NET Identity 2.0 for authentication and I added SignalR to the project so now I have two Startup.cs files:</p>
  
  <p>First one from MVC in the root</p>
  
  <pre><code>[assembly: OwinStartupAttribute(typeof(MCWeb_3SR.Startup))]
  namespace MCWeb_3SR
  {
      public partial class Startup
      {
          public void Configuration(IAppBuilder app)
          {
              ConfigureAuth(app);
  
          }
      }
  }
  </code></pre>
  
  <p>And SignalR one in AppCode folder</p>
  
  <pre><code>[assembly: OwinStartup(typeof(SignalRChat.Startup))]
  namespace SignalRChat
  {
      public class Startup
      {
          public void Configuration(IAppBuilder app)
          {
  
              var heartBeat = GlobalHost.DependencyResolver.Resolve&lt;ITransportHeartbeat&gt;();
  
              var monitor = new PresenceMonitor(heartBeat);
              monitor.StartMonitoring();
  
  
              // Any connection or hub wire up and configuration should go here
              app.MapSignalR();
          }
      }
  }
  </code></pre>
  
  <p>but I get the following error</p>
  
  <p>The following errors occurred while attempting to load the app.
  - The OwinStartup attribute discovered in assembly 'MCWeb-3SR' referencing startup type 'MCWeb_3SR.Startup' conflicts with the attribute in assembly 'App_Code.hszoxs_z' referencing startup type 'SignalRChat.ChatStartup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly.
  To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
  To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.</p>
  
  <p>I tried adding</p>
  
  <pre><code>[assembly: OwinStartupAttribute("ProductionConfiguration.st", typeof(MCWeb_3SR.Startup))]
  </code></pre>
  
  <p>to the first one, page runs but authentication wont work.</p>
  
  <p>How can I have both of them run together ?</p>
  
  <h2>Update</h2>
  
  <pre><code>using System;
  using Microsoft.AspNet.Identity;
  using Microsoft.AspNet.Identity.Owin;
  using Microsoft.Owin;
  using Microsoft.Owin.Security.Cookies;
  using Microsoft.Owin.Security.Google;
  using Owin;
  using MCWeb_3SR.Models;
  
  namespace MCWeb_3SR
  {
      public partial class Startup
      {
          // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
          public void ConfigureAuth(IAppBuilder app)
          {
              // Configure the db context, user manager and signin manager to use a single instance per request
              app.CreatePerOwinContext(ApplicationDbContext.Create);
              app.CreatePerOwinContext&lt;ApplicationUserManager&gt;(ApplicationUserManager.Create);
              app.CreatePerOwinContext&lt;ApplicationSignInManager&gt;(ApplicationSignInManager.Create);
  
              // Enable the application to use a cookie to store information for the signed in user
              // and to use a cookie to temporarily store information about a user logging in with a third party login provider
              // Configure the sign in cookie
              app.UseCookieAuthentication(new CookieAuthenticationOptions
              {
                  AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                  LoginPath = new PathString("/Account/Login"),
                  Provider = new CookieAuthenticationProvider
                  {
                      // Enables the application to validate the security stamp when the user logs in.
                      // This is a security feature which is used when you change a password or add an external login to your account.  
                      OnValidateIdentity = SecurityStampValidator.OnValidateIdentity&lt;ApplicationUserManager, ApplicationUser&gt;(
                          validateInterval: TimeSpan.FromMinutes(30),
                          regenerateIdentity: (manager, user) =&gt; user.GenerateUserIdentityAsync(manager))
                  }
              });            
              app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
  
              // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
              app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
  
              // Enables the application to remember the second login verification factor such as phone or email.
              // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
              // This is similar to the RememberMe option when you log in.
              app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
  
              // Uncomment the following lines to enable logging in with third party login providers
              //app.UseMicrosoftAccountAuthentication(
              //    clientId: "",
              //    clientSecret: "");
  
              //app.UseTwitterAuthentication(
              //   consumerKey: "",
              //   consumerSecret: "");
  
              //app.UseFacebookAuthentication(
              //   appId: "",
              //   appSecret: "");
  
              //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
              //{
              //    ClientId = "",
              //    ClientSecret = ""
              //});
          }
      }
  }
  </code></pre>