Imはasp.netとC#を使用してウェブサイトを作り、非常に最初のページでは、ログインされ、HTMLは、基本的には2つのテキストフィールドと1つのボタンでウィッヒリクエスト以下の機能:
protected void Button1_Click(object sender, EventArgs e)
{
ServicioIS.Service1SoapClient objeto = new ServicioIS.Service1SoapClient();
string a = ci.Value.ToString();
string b = pass.Value.ToString();
// bool x = objeto.Log(a,b);
bool flag = false;
SqlConnection con = new SqlConnection();
con.ConnectionString = "Server=.;database=Proyecto.mdf;user=;password=";
con.Open();
string check = "SELECT COUNT(*) FROM Admin WHERE login ='" + a + "'";
SqlCommand com = new SqlCommand(check, con);
int cont = Convert.ToInt32(com.ExecuteScalar().ToString());
con.Close();
if (cont == 1)
{
con.Open();
string checkpass = "SELECT pass FROM Admin WHERE login = '" + a + "'";
SqlCommand ds = new SqlCommand(checkpass, con);
string contra = ds.ExecuteScalar().ToString().Replace(" ", "");
con.Close();
if (a == contra)
{
flag = true;
}
}
if (flag)
{
Response.Write("Contraseña Correcta");
}
else
{
Response.Write("usuario o contraseña invalidos");
}
}
エラーとスタックトレースは以下の通りです:
Line 31: SqlConnection con = new SqlConnection();
Line 32: con.ConnectionString = " "Server=.;database=Proyecto.mdf;user=;password=";
Line 33: con.Open();
Line 34: string check = "SELECT COUNT(*) FROM Admin WHERE login ='" + a + "'";
Line 35: SqlCommand com = new SqlCommand(check, con);
Source File: c:\Users\Fabrizio\Desktop\Nueva carpeta (2)\ProyectoIS\WebAppIS\WebAppIS\Interface\Login.aspx.cs Line: 33
Stack Trace:
[SqlException (0x80131904): Login failed for user ''.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5347119
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +546
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +1693
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +69
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +30
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +317
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +892
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +311
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData) +646
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +278
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +38
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +732
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +85
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1057
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +196
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +146
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +16
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +94
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +110
System.Data.SqlClient.SqlConnection.Open() +96
WebAppIS.Interface.Login.Button1_Click(Object sender, EventArgs e) in c:\Users\Fabrizio\Desktop\Nueva carpeta (2)\ProyectoIS\WebAppIS\WebAppIS\Interface\Login.aspx.cs:33
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9627718
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
PD:それはどんな簡単にそれを修正することができた場合イムは、Visual Studio 2012を使用して:)
あなたにはSQLインジェクションの脆弱性があります。 – SLaks
あなたの接続文字列にはユーザーがいないので、コピーペーストのエラーはどれくらいか分かりません... 'Server = .; database = Proyecto.mdf; user =; password = 'スタックトレース、それはあなたの問題です。 – Kritner
また、SQLインジェクション、あなたは入力をパラメータ化する必要があります – Kritner