Muhamad Taqi Muhamad Taqi - 8 months ago 100
ASP.NET (C#) Question

asp.net Redirect To a Particular Page which name is in database column with user authentication?

I have a user table in which i have a column where i insert Dashboards where i want User to navigate after login. I am not good in asp.net. I want help that how would i navigate to page with user which i have in my database column.

I have done this so far

protected void btn_login_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=MAAK-EDOOR;Initial Catalog=db_Security_Model;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "[dbo].[Validate_User]";
cmd.Parameters.AddWithValue("@Login", txt_username.Text);
cmd.Parameters.AddWithValue("@Password", txt_password.Text);
SqlDataReader sdr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
try
{//txt_username.Text == cmd.Parameters["@Login"].ToString()) && (txt_password.Text == cmd.Parameters["@Password"].ToString())
if ((cmd.Parameters["@Login"] != null) && (cmd.Parameters["@Password"]!= null))
{//cmd.Parameters["@PageLink"].ToString()

// Response.Redirect();
}
else
{
lbl_invalid.Text = "Ivalid UserName or Password";
}
}
catch (Exception ex)
{

}
}

Answer Source

You can Navigate to the another page using the

Response.Redirect("Page_URL");

For Passing the Database Column you can use the Session

Storing the Value in the Session in Login Page as follows

Session["DbcolumnValue"] ="YOur Value coming from DB";

In another Page you can access the session value as follows

if(Session["DbcolumnValue"]!= null)
{
string value = Session["DbcolumnValue"].ToString();
}