User Authentication Should Display

Posted by Self-Innovator under ASP.NET on 4/5/2012 | Points: 10 | Views : 1373 | Status : [Member] | Replies : 5
Hi...
I've and Login Formbased n user Id and passwrd is correct of User then it redirects to HomePage from login page..

but In my Scenario when i Copy & Paste the url of Home Page and enters directly it allows hoe to avoid this ....Pls tel me soln...

Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Yuvaopens on: 4/5/2012 [Member] Starter | Points: 25

Up
0
Down
Make it with session state and make the view state as false............... After that also it may go, but if u move on with the operations inside that page it will not allow u to work in that page........

Yuvaraj.S

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/5/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi thank for ur response..
Will u pls Write Some Code How to achieve this...

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 4/6/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

If you are using form Authentication then
in webconfig file write this code


<authentication mode="Forms">
<forms name="Default" loginUrl="logon.aspx" />
</authentication>

<authorization>
<deny users ="?" />
<allow users = "*" />
</authorization>


R D Patel

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 4/6/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

Is it work or Not?
Let me know

R D Patel

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 4/7/2012 [Member] Bronze | Points: 25

Up
0
Down
Ya this wrks ...I kew this One...
But Chek my Code wre I've Created My Login...Based on this provide me an Authentication...

On Login Click
string UserId = txtUser.Text.Trim();

Session["UserId"] = UserId;
String Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(),"MD5");
try
{
int i = 0, j = 0;
int count = 0;
SqlConnection cnn = new SqlConnection(Conn);
SqlCommand cmd = new SqlCommand("spGetUsers", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserId", UserId);
cmd.Parameters.AddWithValue("@Pwd", Pwd);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
UserId = "";
if (ds.Tables[0].Rows.Count >0)
{
if(Pwd==ds.Tables[0].Rows[0]["Password"].ToString());
Response.Redirect("To SomePage.aspx");
}


Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response