ASP.NET MVC OWIN und SignalR - zwei Starts.cs-Dateien

Ich habe ein problem mit meinem Projekt.

Ich verwenden ASP.NET MVC mit ASP.NET Identität 2.0 für die Authentifizierung und ich fügte hinzu, SignalR, um das Projekt so, jetzt habe ich zwei Starts.cs-Dateien:

Erste von MVC in das root -

[assembly: OwinStartupAttribute(typeof(MCWeb_3SR.Startup))]
namespace MCWeb_3SR
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);

        }
    }
}

Und SignalR ist eine in AppCode Ordner

[assembly: OwinStartup(typeof(SignalRChat.Startup))]
namespace SignalRChat
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {

            var heartBeat = GlobalHost.DependencyResolver.Resolve<ITransportHeartbeat>();

            var monitor = new PresenceMonitor(heartBeat);
            monitor.StartMonitoring();


            //Any connection or hub wire up and configuration should go here
            app.MapSignalR();
        }
    }
}

aber ich bekomme die folgende Fehlermeldung

Folgende Fehler aufgetreten beim laden der app.
- Die OwinStartup Attribut vor in-assembly "MCWeb-3SR' verweisen auf Starttyp 'MCWeb_3SR.Startup' Konflikte mit dem Attribut in der assembly 'App_Code.hszoxs_z' verweisen auf Starttyp 'SignalRChat.ChatStartup', weil Sie die gleichen FriendlyName ". Entfernen Sie oder benennen Sie eines der Attribute, oder einen Verweis auf die gewünschte Art direkt.
Deaktivieren OWIN startup Entdeckung, fügen Sie die " appSetting owin:AutomaticAppStartup mit einem Wert von "false" in Ihrer Website.config.
Angeben der OWIN startup-Montage, Klasse oder Methode, fügen Sie die " appSetting owin:AppStartup mit dem voll qualifizierten startup-Klasse oder Konfiguration name der Methode in Ihrer Website.config.

Habe ich versucht, indem

[assembly: OwinStartupAttribute("ProductionConfiguration.st", typeof(MCWeb_3SR.Startup))]

dem ersten, Seite läuft aber die Authentifizierung klappt nicht.

Wie kann ich beide zusammen laufen ?

Update

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<ApplicationUserManager>(ApplicationUserManager.Create);
            app.CreatePerOwinContext<ApplicationSignInManager>(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<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => 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 = ""
            //});
        }
    }
}
  • Ändern Sie die Start-Klasse OWIN verwendet
  • Ich brauche beide Klassen - die eine ist für die Authentifizierung und die andere ist für SignalR
  • Können Sie nicht alle Konfigurations-content in eine Methode und die Verwendung von 2 Parametern? z.B. [assembly: OwinStartupAttribute(typeof(MCWeb_3SR.Start))] [assembly: OwinStartup(typeof(MCWeb_3SR.Startup -))]
  • Ich habe versucht, vor, aber, wenn ich keinen Zugriff auf App_Code-Ordner von root Starten.cs und I cant get ConfigureAuth(app) von der anderen.
  • OwinStartup und OwinStartupAttribute sind die gleiche Sache. Sie Zusammenführen müssen die 2 Dateien in 1 Datei, die die Konfiguration für die signalr und mvc/webapi
  • Ich bekomme Den Namen 'ConfigureAuth' existiert nicht im aktuellen Kontext
  • Hast du die Klasse partial @exe.Fledermaus?
  • Hatte ich auch, aber ich bekomme immer noch ConfigureAuth Fehler @danludwig - die Datei ist im Ordner App_Code.
  • ist es ein Startup.Auth.cs-Datei in Ihrem App_Start-Ordner? Wenn ja, bitte posten, wie es ist, wo die ConfigureAuth Methode Umsetzung sein sollte.
  • Ich aktualisierte die Frage mit der Inbetriebnahme.Auth.cs-Datei - es ist generisch, die kam mit dem Projekt @danludwig
  • Lassen Sie uns weiter, diese Diskussion im chat.

InformationsquelleAutor exe.bat | 2015-07-17
Schreibe einen Kommentar