データベースがIBM iシリーズサーバー上にあるASP.NET MVCアプリケーションがあります。私はポップアップThe ConnectionString property is invalid.
エラーを取得するために始めたとき、私は近い完了までのアプリケーション開発を持っている:"ConnectionStringプロパティは無効です。"私がそれが有効であることを知っているとき
- のみ
- 上のログで、誰がログオンし
- を再構築した後の最初の成功のログがまだ正常に動作することができた後、
また、この問題は私のソリューションの1つのプロジェクトにしか表示されません。もう1つのプロジェクトはまったく同じ接続文字列を使用しており、この問題は発生しません(コピーして100%確実に貼り付けられます)。私はこれらのプロジェクトについて積極的に開発していますが、接続文字列に触れていないし、AccountController
と関連するモデルクラスを使用してログインしても問題はありません。
私はVisual Studio 2008と.NET version 3.5を使用しています。
接続文字列:
<connectionStrings>
<add name="IbmIConnectionString" connectionString="DataSource=192.168.50.200;DefaultCollection=QMFILES;Naming=sql;UserID=XXX;Password=XXXX;"/>
</connectionStrings>
アカウントコントローラのログオン方法:
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
string fullName = String.Empty;
string employeeId = String.Empty;
if (ModelState.IsValid)
{
if (MembershipService.ValidateUser(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
EmployeeLoginModel elm = new EmployeeLoginModel();
elm.GetUserInfo(model.UserName, model.Password, out fullName, out employeeId);
// Update the AuthCookie to include the last 4 digits of the SSN.
string userDataString = String.Format("{0}|{1}|{2}", model.Password, fullName.Trim(), employeeId.Trim());
HttpCookie authCookie = FormsAuthentication.GetAuthCookie(model.UserName, model.RememberMe);
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, userDataString);
authCookie.Value = FormsAuthentication.Encrypt(newTicket);
Response.Cookies.Add(authCookie);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
従業員ログインモデル:
public class EmployeeLoginModel
{
public string UserName { set; get; }
public string Password { set; get; }
private iDB2Connection conn;
/// <summary>
/// Initializes a new instance of the <see cref="EmployeeLoginModel"/> class.
/// </summary>
public EmployeeLoginModel()
{
conn = new iDB2Connection(ConfigurationManager.ConnectionStrings["IbmIConnectionString"].ConnectionString);
}
/// <summary>
/// Determines whether [is valid user] [the specified username].
/// </summary>
/// <param name="username">The username.</param>
/// <param name="password">The password.</param>
/// <returns>
/// <c>true</c> if [is valid user] [the specified username]; otherwise, <c>false</c>.
/// </returns>
public bool IsValidUser(string username, string password)
{
int count = 0;
// Get the data from the iSeries
using (conn)
{
string sqlStatement = "SELECT COUNT(XXXXX) FROM XXXXX WHERE UPPER(XXXXXX) = @1 AND XXXXXX = @2";
iDB2Command cmd = new iDB2Command(sqlStatement, conn);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("@1", username.ToUpper());
cmd.Parameters.Add("@2", password);
conn.Open();
count = (Int32)cmd.ExecuteScalar();
conn.Close();
}
return ((count == 0) ? false : true);
}
詳細については、おそらく接続文字列、接続文字列の取得方法、アカウントコントローラの外観はどうでしょうか?あなたのSVNログも投稿してください、私はもう "それに触れていない"とは思っていません。 ;) – jfar
あなたはここにあなたのパスワードを記載してもよろしいですか?それがあなたの本当のパスワードなら、私はすぐにそれを変更することをお勧めします...(編集者は編集の履歴を見ることができるので、あなたの投稿を編集するだけで助けになりません) – Eilon
SVNログはバージョン管理されていないため、まだ。 –