2016-12-05 37 views
1

當我將Microsoft.AspNetCore.Identity.EntityFrameworkCore從1.0更新到1.1時,[Authorize]屬性無法重定向到登錄頁面,我只是得到一個空白頁面。從AspNetCore Identity 1.0更新到1.1的問題

是否有人知道是否有任何可能導致此問題的突變?

我使用的是默認/帳號/登錄

services.AddIdentity<ApplicationUser, IdentityRole>(options => 
{ 
    options.Password.RequireDigit = Configuration.GetValue<bool>("Identity:Password:RequireDigit"); 
    options.Password.RequiredLength = Configuration.GetValue<int>("Identity:Password:RequiredLength"); 
    options.Password.RequireLowercase = Configuration.GetValue<bool>("Identity:Password:RequireLowercase"); 
    options.Password.RequireNonAlphanumeric = Configuration.GetValue<bool>("Identity:Password:RequireNonAlphanumeric"); 
    options.Password.RequireUppercase = Configuration.GetValue<bool>("Identity:Password:RequireUppercase"); 

    options.Lockout.MaxFailedAccessAttempts = Configuration.GetValue<int>("Identity:Lockout:MaxFailedAccessAttempts"); ; 

    options.SignIn.RequireConfirmedEmail = Configuration.GetValue<bool>("Identity:SignIn:RequireConfirmedEmail"); 

    options.User.RequireUniqueEmail = Configuration.GetValue<bool>("Identity:User:RequireUniqueEmail"); 


}) 
.AddEntityFrameworkStores<ApplicationDbContext>() 
.AddDefaultTokenProviders(); 

我可以與樣板VS 2015年項目複製此。

  1. 新建項目
  2. ASP.NET核心的Web應用程序(.NET核心)
  3. 'Web應用程序' 模板
  4. '個人用戶帳戶' 身份驗證
  5. 打開網站/管理/指數它會重定向到/帳號/登錄
  6. 這些設置爲1.1

    「Microsoft.AspNetCore.Authentication.Co okies「: 」1.1.0「

    」Microsoft.AspNetCore.Identity.EntityFrameworkCore「: 」1.1.0「

    」Microsoft.Extensions.Logging「: 」1.1.0「

  7. 開放網站/管理/指數,它就會打開一個空白頁

我使用.NET 4.6.1,這裏是更新project.json

{ 
    "userSecretsId": "aspnet-MPS.IdentityServer-3b3bb17d-2d5b-4d07-a62f-0c092febc156", 

    "dependencies": { 
    "AspNet.Security.OAuth.Validation": "1.0.0-alpha3-final", 
    "esendex-dotnet-sdk": "2.5.0", 
    "MailKit": "1.10.1", 
    //"Microsoft.AspNet.WebApi.Core": "5.2.3", 
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0", 
    //"Microsoft.AspNetCore.Authentication.Facebook": "1.0.0", 
    //"Microsoft.AspNetCore.Authentication.Google": "1.0.0", 
    //"Microsoft.AspNetCore.Authentication.Twitter": "1.0.0", 
    "Microsoft.AspNetCore.Cors": "1.1.0", 
    "Microsoft.AspNetCore.Diagnostics": "1.1.0", 
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0", 
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0", 
    "Microsoft.AspNetCore.Mvc": "1.1.0", 
    "Microsoft.AspNetCore.Razor.Tools": { 
     "version": "1.1.0-preview4-final", 
     "type": "build" 
    }, 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", 
    "Microsoft.AspNetCore.StaticFiles": "1.1.0", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0", 
    "Microsoft.EntityFrameworkCore.SqlServer.Design": { 
     "version": "1.1.0", 
     "type": "build" 
    }, 
    "Microsoft.EntityFrameworkCore.Tools": { 
     "version": "1.1.0-preview4-final", 
     "type": "build" 
    }, 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", 
    "Microsoft.Extensions.Configuration.Json": "1.1.0", 
    "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0", 
    "Microsoft.Extensions.Logging": "1.1.0", 
    "Microsoft.Extensions.Logging.Console": "1.1.0", 
    "Microsoft.Extensions.Logging.Debug": "1.1.0", 
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0", 
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0", 
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { 
     "version": "1.1.0-preview4-final", 
     "type": "build" 
    }, 
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": { 
     "version": "1.1.0-preview4-final", 
     "type": "build" 
    }, 
    "OpenIddict": "1.0.0-*", 
    "OpenIddict.Mvc": "1.0.0-*", 
    "Serilog.Extensions.Logging": "1.1.0", 
    "Serilog.Settings.Configuration": "2.1.0", 
    "Serilog.Sinks.RollingFile": "2.2.0", 
    "System.Reflection.Extensions": "4.0.0" 
    },  

    "tools": { 
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", 
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", 
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final", 
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": { 
     "version": "1.0.0-preview2-final", 
     "imports": [ 
     "portable-net45+win8" 
     ] 
    } 
    },  

    "frameworks": { 
    "net461": {} 
    }, 

    "buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true 
    },  

    "runtimeOptions": { 
    "configProperties": { 
     "System.GC.Server": true 
    } 
    },  

    "publishOptions": { 
    "include": [ 
     "wwwroot", 
     "Views", 
     "Areas/**/Views", 
     "appsettings*.json", 
     "web.config" 
    ], 
    "exclude": [ 
     "wwwroot/lib/", 
     "wwwroot/_references.js", 
     "wwwroot/css/src", 
     "wwwroot/css/bootstrap-override.css", 
     "wwwroot/js/src", 
     "Views/Account/ExternalLoginConfirmation.cshtml", 
     "Views/Account/ExternalLoginFailure.cshtml", 
     "Views/Manage/ManageLogins.cshtml", 
     "Views/Manage/SetPassword.cshtml" 
    ] 
    },  

    "scripts": { 
    "prepublish": [ "bower install" ], 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    }, 

    "configurations": { 
    "Test": {} 
    }   
} 

回答

3

更新如下:

"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", 

"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", 

我怎麼想通了:我通過紅隼跑到獲得命令行輸出窗口希望能看到一個錯誤。相反,它的工作。所以我意識到在IIS集成中必須有新的東西。

+0

謝謝。我已經嘗試將IISIntegration設置爲1.1以及其他,但仍然失敗 – Dave

+0

真的嗎?我剛剛重新執行了一個全新項目的步驟,並將4個軟件包(您的3 + my 1)設置爲1.1.0,並且按照預期的方式使用登錄重定向。也許這是一個在我的機器問題上的作品,我有不同的東西安裝。可悲的是,我不知道如何解決這個問題。 –

+0

@Dave作爲一個完整的檢查,我在另一臺計算機上再次嘗試同樣的事情。相同的步驟:新項目,添加3個版本更新並且不起作用。添加IISIntegration版本更新並開始工作。不知道你可能已經改變了什麼。你從一個新項目嘗試了嗎? –