現在、Oracle データベースを使用した ASP.NET MVC 4 プロジェクトに取り組んでいます。次のように、Web.config ファイルに接続文字列を正常に追加しました。
<add name="OracleDBConnString" connectionString="Provider=MSDAORA;Data Source=ISDQA;User ID=isd;Password=isdqa;" providerName="System.Data.OleDB" />
しかし、新しいプロジェクトを作成すると、組み込みの認証クラスが既に含まれています。これらのクラスを一度だけ変更するにはどうすればよいですか? デフォルトを変更したい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);
}
アップデート
を に変更する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;
していることに注意してください。