Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 登录后使网站上的页面可访问_C#_Authentication_Login - Fatal编程技术网

C# 登录后使网站上的页面可访问

C# 登录后使网站上的页面可访问,c#,authentication,login,C#,Authentication,Login,我需要一个背后的代码,我可以使用它使一个网站上的网页通过登录认证后可访问,这意味着我希望它是可访问的,当一个特定的用户只登录。 任何能帮我的人 (注:我比较瘦,还是个新手) 提前感谢表格自动认证如何 然后是我为u编写的一个非常简单的程序 readonly SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["VerbaLinksConString"].ToString()); try

我需要一个背后的代码,我可以使用它使一个网站上的网页通过登录认证后可访问,这意味着我希望它是可访问的,当一个特定的用户只登录。 任何能帮我的人

(注:我比较瘦,还是个新手)


提前感谢

表格自动认证如何

然后是我为u编写的一个非常简单的程序

 readonly SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["VerbaLinksConString"].ToString());

 try
 {
    SqlCommand cmd  = new SqlCommand("Select txt_Password from table where txt_user_name = '"+txtUserName.Text+"' and txt_Pwd = '"+txtPassword.Text+"'",sqlCon);
   sqlCon.Open();
   SqlDataReader dr = cmd.ExecuteReader();
   If(dr.Read())
   {
     Response.Redirect("HomePage.aspx");
   }
   else
   {
     Response.Write("Either userId or Password is wrong");
   }
   SqlCon.Close(); 
}
Catch(SqlException ex)
 {

 }

您是否有任何包含登录凭据的数据库表欢迎使用SO。请阅读“是的,我有它”@Rajeev KumarThanks嘿,真的很感激它,它的工作方式正是我想要的!:-)用户登录后是否也可以访问另一个页面?