Is it possible to allow both authenticated and none authenticated users on a particular page, they can view content on that page but ones they click any button on that page the none authenticated user will be rediredted to logn page
here is the code i use buth it just redirecting none authenticated users ones they land on the page
if (HttpContext.Current.Session["userName"] == null)
{
Response.RedirectToRoute("HomePage");
}
else
{
if (!this.IsPostBack)
{
this.Populate();
}
}
}
private void Populate()
{
string Populate = "GetUSERPost";
using (SqlConnection con = new SqlConnection(constring4))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(Populate, con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Id", string.IsNullOrEmpty(Request.QueryString["Id"]) ? Page.RouteData.Values["Id"].ToString() : Request.QueryString["Id"].ToString());
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
ViewState["DataTable"] = dt;
GetAll.DataSource = dt;
GetAll.DataBind();
}
}