stop Direct url access to webpage

Posted by Hary.jack under Regular Expressions on 5/29/2011 | Points: 10 | Views : 8225 | Status : [Member] | Replies : 5
Hi ALL,

Can any body tell me , how to stop Direct url access to any webpage of any website when all page all store in root directory of website?
i have 2 section for user & admin. for eg http://www.dotnetfunda.com/PostQuestions.aspx
i want to stop direct url writting for access for postQuestions.aspex , if any body type this then he/they will direct to authencation check page otherwise redirect to errorpag

in my website some page doesn't contain any session.

how i implement this, plz suggest me.




Responses

Posted by: Ndebata on: 5/30/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
In the OnInt of the Specific Page check, if user has logged in or not, If not then just call Response.Redirect("Login.aspx").

Thanks,
Debata

Hary.jack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 5/30/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi


u do with cookies . . after Login u This Code add ur every Page on page load ..

  if (Request.Cookies["username"] == null)

{
Response.Redirect("~/Login.aspx?msg=Please login through your Login-ID and Password");
}


Best Regard's
Prabhakar

Hary.jack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lokesh76 on: 5/30/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
Its seems that you are not using any authentication in your website implement authentication in website. Suppose if you implement forms based authentication in you website and any user directly type any page url its redirect to default page as given by you in defaultUrl setting because typed url page don't have authentication cookies associated.

Please refer this link for authentication implementation

http://msdn.microsoft.com/en-us/library/ff647070.aspx

Thanks
Lokesh Kumar

Hary.jack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 5/31/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
a Session exist on the Browser, when the Browser is closed the Session gets lost. So in all your pages that should be visible when someone is logged in, you need to check if the Session is not nulll

if(Session["Username"] != null)
{
Response.redirect("Login.aspx",false);
}


now this will work if abondon the session the the User logs out.



Thank you for posting at Dotnetfunda
[Administrator]

Hary.jack, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 6/1/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
why didnot Handled Session or Cookie that's user Friendly track correctly your application after restrict url best way try this one




Mark as Answer if its helpful to you

Hary.jack, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response