Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

On login if one of my db value is true then i don't want to show a menu which is redirecting to certain page, i did it.
but if someone knows page name and write direct to address bar then he/she can go to that page.

so how can i do it if someone write page name to address bar but if my db value is true then i want them redirect to home page.

thanks,
kk
Posted
Comments
Thanks7872 17-May-13 5:06am    
You are making menu visible at some time.Check db value before showing the menu.If its true dont show it.Whats issue with this? If you want to prevent unauthorised access to the page then you can make use of Forms authentication.
kk2014 17-May-13 5:56am    
hi,
in short i don't want to redirect to page test.aspx if flag=1.
thanks

On every page make a check whether DB value is true, if it is true then redirect to Home Page.
 
Share this answer
 
Comments
kk2014 17-May-13 5:48am    
hi,
in short i don't want to redirect to page test.aspx if flag=1.
thanks
One of the way to do this, is to use Global.asax BeginRequest event as given below or you can create Base Page and derive all the aspx pages on which you want to stop user to come directly.In load method of base page you validate user request and redirect them to home page.

protected void Application_BeginRequest(object sender, EventArgs e)
{
bool dbValue;
//Get Value From DataBase for bdValue

if(Path.GetFileName(HttpContext.Current.Request.PhysicalPath) == "test.aspx" && dbValue)
{
HttpContext.Current.Response.Redirect("Home.aspx");
}

}
 
Share this answer
 
hi all,

i found the solution...
i code this in my master page and it worls for me.
please see below code:

C#
if (System.IO.Path.GetFileName(HttpContext.Current.Request.PhysicalPath) == "test.aspx" && showWebbkg == 1)
{
                HttpContext.Current.Response.Redirect("Home.aspx");
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900