據我所知,MVC 5配備了新的OWIN/ASP.NET身份認證位。在一個新的MVC 5項目的web.config文件,其實我注意到,FormsAuthenticationModule
被禁用
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
此外,還有是在App_Start文件夾名爲Startup.Auth.cs創建一個新文件。在這個文件中的與「/帳號/登錄」的默認登錄路徑
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
嘗試更改爲您的應用正確的路徑是路徑,CookieAuthenticationOptions
(新FormsAuthentication名稱)的定義。或者,您無法使用新的ASP.NET標識位,並刪除web.config中刪除FormsAuthenticationModule
的行。
如果你不使用或想要使用新的身份驗證選項,在您的應用程序的根目錄中刪除調用ConfigureAuth()
在Startup.cs
文件並刪除上面的行中刪除FormsAuthenticationModule
web.config中。這應該恢復預期的行爲(同樣,不知道你對默認代碼做了多少定製)。
你可以添加'標籤在你的web.config中? –
ekad
2014-09-22 07:35:51
奇怪的是,嘗試搜索當前的「login」或「account/login」項目與「匹配全字」選項打勾。如果您的項目中沒有任何地方提及「登錄」或「帳戶/登錄」網址,則可能是IIS中的設置。 – ekad 2014-09-22 07:57:28