2016-04-25 49 views
0

我發現很多問題一樣,以我的問題,但他們不解決我的問題視圖「索引」或它的主人沒有被發現,這是因爲用戶身份憑證無效

生病解釋這個簡單,我已經創建MVC 5 web應用程序。在該應用程序 一旦調試我的應用程序其引導到~/Account/Login

那麼一旦我插入有效的用戶名密碼,就可以直接到~/Home/Index

這個應用程序以前運行良好,但後來我改成了本地數據庫

這怎麼服務器DB以前

 <connectionStrings> 
     <add name="dbconnection" connectionString="Data Source=192.158.1.205;Initial Catalog=DBName;Persist Security Info=True;User ID=**;Password=****" providerName="System.Data.SqlClient" /> 
     <add name="DefaultConnection" connectionString="Data Source=192.158.1.205;Initial Catalog=DBName;Persist Security Info=true;User ID=**;Password=****" providerName="System.Data.SqlClient" /> 
     <add name="ProjectEntities" connectionString="metadata=res://*/Models.albaraka_model.csdl|res://*/Models.albaraka_model.ssdl|res://*/Models.DBName_model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=192.158.1.205;initial catalog=***;persist security info=True;user id=***;password=*****;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

定義的連接字符串

這是如何配置的連接字符串本地數據庫現在

<connectionStrings> 
    <add name="dbconnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=DBName;Integrated Security=True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> 
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=DBName;Integrated Security=True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> 
    <add name="ProjectEntities" connectionString="metadata=res://*/Models.DBName_model.csdl|res://*/Models.DBName_model.ssdl|res://*/Models.DBName_model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=ALBARAKA;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 

這是因爲無效的連接字符串定義?或者這是因爲無效的用戶名密碼(目前它不是在客戶端或服務器端處理)

這是登錄方法的我POST方法

 [HttpPost] 
     [AllowAnonymous] 
     [ValidateAntiForgeryToken] 
     public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) 
     { 

      if (!ModelState.IsValid) 
      { 
       return View(model); 
      } 


      var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false); 

      switch (result) 
      { 
       case SignInStatus.Success: 
        return RedirectToLocal(returnUrl); 

       case SignInStatus.LockedOut: 
        return View("Lockout"); 

       case SignInStatus.RequiresVerification: 
        return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); 

       case SignInStatus.Failure: 

       default: 
        ModelState.AddModelError("", "Invalid login attempt."); 

        return View("Index", "Home", model); 
      } 
     } 

真的很感謝你的幫助

+0

無它,因爲它尋找'View',它不能找到它 – jamiedanq

+0

@jamiedanq但我可以看到它位於正確的文件夾:( –

回答

1

更改此

return View("Index", "Home", model); 

的意見FULLPATH和模型

return View("~/Views/Index.cshtml", model); //note this is an example so replace the path with yours 

return RedirectToAction("Index","Home"); 

return RedirectToAction("Index","Home", model); 

參考,如果您需要這個環節進一步澄清https://msdn.microsoft.com/en-us/library/system.web.mvc.controller.redirecttoaction(v=vs.118).aspx

+0

最新情況模型返回 –

+0

你可以添加以及 – jamiedanq

+1

非常感謝它工作:) –

相關問題