我目前正在使用Oracle數據庫處理ASP.NET MVC 4項目。我已經成功添加連接字符串在我的Web.config文件喜歡這裏:使用Oracle數據庫配置ASP.NET MVC 4應用程序
3210但是,當我創建一個新項目,它已經有一個內置的身份驗證類。我怎樣才能一次又一次修改這些類? 我想更改默認的ConnString
。
這裏是我的模型:
public class UsersContext : DbContext
{
public UsersContext()
: base("OracleDBConnString")
{
}
public DbSet<UserProfile> UserProfiles { get; set; }
}
public class LoginModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
這裏是我的用戶控制器:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
//I WANT TO MODIFY THIS PART
if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
{
return RedirectToLocal(returnUrl);
}
// If we got this far, something failed, redisplay form
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
UPDATE
當我改變base("DefaultConnection")
到base("OracleDBConnString")
,我得到這個錯誤:
Server Error in '/' Application.
A null was returned after calling the 'get_ProviderFactory' method on a store provider instance of type 'System.Data.OleDb.OleDbConnection'. The store provider might not be functioning correctly.
請注意,我已在我的使用中添加了using System.Data.OleDb;
。
我不明白。我必須更改連接字符串嗎? –
順便說一下,我安裝了CodeFirst成員提供程序。 –
@garath您能否向我解釋如何設置Oracle MemberShip提供程序在此處查看我的答案:http://stackoverflow.com/questions/23094959/using-oracle-membership-provider-in-asp-net-mvc – Chlebta