Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 403禁止的错误。具有Cookie身份验证的MVC5Web项目_C#_Asp.net_.net_Asp.net Mvc_Iis - Fatal编程技术网

C# 403禁止的错误。具有Cookie身份验证的MVC5Web项目

C# 403禁止的错误。具有Cookie身份验证的MVC5Web项目,c#,asp.net,.net,asp.net-mvc,iis,C#,Asp.net,.net,Asp.net Mvc,Iis,我从我的MVC Web项目中得到了一些奇怪的行为 我正在使用MVC5和.net4.6.1。Auth与Cookie身份验证一起使用 我的发布选项是可预编译的,可更新选项设置为True 当我发布我的WebApp时,我单击发布,获取文件夹内容并将其复制到我的CloudServer(IIS 8.5) 所有的东西都能找到,直到某一点(不能确切地说什么时候(几个小时))我得到一个403错误,需要重新发布我的webapp 你知道问题出在哪里吗 马库斯 更新1 public partial class S

我从我的MVC Web项目中得到了一些奇怪的行为

我正在使用MVC5和.net4.6.1。Auth与Cookie身份验证一起使用

我的发布选项是可预编译的,可更新选项设置为True

当我发布我的WebApp时,我单击发布,获取文件夹内容并将其复制到我的CloudServer(IIS 8.5)

所有的东西都能找到,直到某一点(不能确切地说什么时候(几个小时))我得到一个403错误,需要重新发布我的webapp

你知道问题出在哪里吗

马库斯

更新1

   public partial class Startup
{
    // Anwendung für die Verwendung von "OAuthAuthorization" aktivieren. Anschließend können Sie Ihre Web-APIs sichern.
    static Startup()
    {
        PublicClientId = "web";

        OAuthOptions = new OAuthAuthorizationServerOptions
        {
            TokenEndpointPath = new PathString("/Token"),
            AuthorizeEndpointPath = new PathString("/Account/Authorize"),
            Provider = new ApplicationOAuthProvider(PublicClientId),
            AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(60),
            AllowInsecureHttp = true
        };
    }

    public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }

    public static string PublicClientId { get; private set; }

    // Weitere Informationen zum Konfigurieren der Authentifizierung finden Sie unter "http://go.microsoft.com/fwlink/?LinkId=301864".
    public void ConfigureAuth(IAppBuilder app)
    {
        // Konfigurieren des db-Kontexts, des Benutzer-Managers und des Anmelde-Managers für die Verwendung einer einzelnen Instanz pro Anforderung.
        app.CreatePerOwinContext(ApplicationDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

        // Anwendung für die Verwendung eines Cookies zum Speichern von Informationen für den angemeldeten Benutzer aktivieren
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            ExpireTimeSpan = TimeSpan.FromMinutes(30),
            LogoutPath = new PathString("/Account/LogOff"),
            Provider = new CookieAuthenticationProvider
            {
                // Aktiviert die Anwendung für die Überprüfung des Sicherheitsstempels, wenn sich der Benutzer anmeldet.
                // Dies ist eine Sicherheitsfunktion, die verwendet wird, wenn Sie ein Kennwort ändern oder Ihrem Konto eine externe Anmeldung hinzufügen.  
                OnValidateIdentity = SecurityStampValidator
            .OnValidateIdentity<ApplicationUserManager, ApplicationUser, Guid>(
                validateInterval: TimeSpan.FromMinutes(60),
                regenerateIdentityCallback: (manager, user) =>
                    user.GenerateUserIdentityAsync(manager),
                getUserIdCallback: (id) => new Guid((id.GetUserId())))
            }
        });
        // Ein Cookie zum vorübergehenden Speichern von Informationen zu einem Benutzer verwenden, der sich mit dem Anmeldeanbieter eines Drittanbieters anmeldet
        app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

        // Aktiviert die Anwendung für das vorübergehende Speichern von Benutzerinformationen beim Überprüfen der zweiten Stufe im zweistufigen Authentifizierungsvorgang.
        app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(60));

        // Aktiviert die Anwendung für das Speichern der zweiten Anmeldeüberprüfungsstufe (z. B. Telefon oder E-Mail).
        // Wenn Sie diese Option aktivieren, wird Ihr zweiter Überprüfungsschritt während des Anmeldevorgangs auf dem Gerät gespeichert, von dem aus Sie sich angemeldet haben.
        // Dies ähnelt der RememberMe-Option bei der Anmeldung.
        app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);

        // Anwendung für die Verwendung eines Trägertokens zum Authentifizieren von Benutzern aktivieren
        app.UseOAuthBearerTokens(OAuthOptions);

        // Auskommentierung der folgenden Zeilen aufheben, um die Anmeldung mit Anmeldeanbietern von Drittanbietern zu ermöglichen
        //app.UseMicrosoftAccountAuthentication(
        //    clientId: "",
        //    clientSecret: "");

        //app.UseTwitterAuthentication(
        //    consumerKey: "",
        //    consumerSecret: "");

        //app.UseFacebookAuthentication(
        //    appId: "",
        //    appSecret: "");

        //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
        //{
        //    ClientId = "",
        //    ClientSecret = ""
        //});
    }
}
公共部分类启动
{
//Anwendung für die Verwendung von“OAuthAuthorization”aktivieren.Anschließend könne是一个网络API的开发者。
静态启动()
{
PublicClientId=“web”;
OAuthOptions=新的OAuthAuthorizationServerOptions
{
TokenEndpointPath=新路径字符串(“/Token”),
AuthorizeEndpointPath=新路径字符串(“/Account/Authorize”),
Provider=新的ApplicationAuthProvider(PublicClientId),
AccessTokenExpireTimeSpan=TimeSpan.FromMinutes(60),
AllowInsecureHttp=true
};
}
公共静态OAuthAuthorizationServerOptions OAuthOptions{get;private set;}
公共静态字符串PublicClientId{get;private set;}
//您可以在“您的身份验证”中查看您的个人信息http://go.microsoft.com/fwlink/?LinkId=301864".
public void ConfigureAuth(IAppBuilder应用程序)
{
//在db文本中,管理者和管理者都是专业人士。
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext(ApplicationUserManager.Create);
app.CreatePerOwinContext(ApplicationSignInManager.Create);
//这是一个非常有趣的故事,因为它是一个信息时代的主题
app.UseCookieAuthentication(新的CookieAuthenticationOptions
{
AuthenticationType=DefaultAuthenticationTypes.ApplicationOkie,
LoginPath=新路径字符串(“/Account/Login”),
ExpireTimeSpan=时间跨度从分钟(30),
LogoutPath=新路径字符串(“/Account/LogOff”),
Provider=新CookieAuthenticationProvider
{
//这是一个很好的选择,因为它是一个很好的选择。
//这是一个很好的例子,但它是一个很好的例子。
OnValidateIdentity=SecurityStampValidator
.OnValidateId实体(
validateInterval:TimeSpan.FromMinutes(60),
regenerateIdentityCallback:(管理者,用户)=>
user.GenerateUserIdentityAsync(管理器),
getUserIdCallback:(id)=>新Guid((id.GetUserId()))
}
});
//这是一个非常重要的信息来源,它是一个非常重要的信息来源
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
//这是一个非常重要的问题,因为它是一个非常重要的问题。
app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie,TimeSpan.FromMinutes(60));
//这是一个非常好的例子(z.B.Telefon oder E-Mail)。
//如果你选择了另一种方式,那么你可以选择一种新的方式,让你的父母在你的家庭中生活。
//在安梅尔敦的记忆选择中死亡。
app.useTowFactoryMemberBrowserCookie(DefaultAuthenticationTypes.TwoFactoryRememberBrowserCookie);
//这本书是作者的著作
应用程序使用OAuthBealerTokens(OAuthOptions);
//如果你是一个自由人,那么你可以把你的名字改成一个名字
//app.UseMicrosoftAccountAuthentication(
//客户ID:“,
//客户机密:);
//app.UseTwitterAuthentication(
//消费市场:“,
//消费者信用:”;
//app.UseFacebookAuthentication(
//appId:“”,
//appSecret:”;
//app.UseGoogleAuthentication(新的GoogleOAuth2AuthenticationOptions()
//{
//ClientId=“”,
//ClientSecret=“”
//});
}
}

我在Assemblyinfo中犯了一个错误,导致了崩溃

//Correct 
[assembly: AssemblyCulture("")]

//Caused the Crash
[assembly: AssemblyCulture("de-DE")]

403错误何时出现?请包括错误消息的详细信息以及当错误再次发生时您所做的任何操作。您是否有子代码?这可能是由于会话超时或cookie过期,再加上重定向到登录页面的操作不正常造成的?毫无疑问。昨天我发布了这个项目。现在今天早上它不工作了。这是来自IIS的403拒绝访问错误。我尝试了不同的应用程序池,SSL和No-SSL。重新启动服务器,重新启动IIS。如果没有重复出现问题,我们只能猜测。您至少可以尝试通过解释错误来帮助其他人解决此问题。这个答案没有任何价值,除了你的接受评级,没有任何信息。编辑我的答案