Click here to Skip to main content
15,942,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have worked on one application do login the application and enter the timesheets, but the error is without logged in to the site if we give direct url it is getting the timesheet page directly how to stop this. if url is entered also it shouldn't allow user to direct page it should default show "Login" page how it can be done.
Posted

1 solution

Solution 1 :
Please set the following setting in web.confign file :
XML
<authentication mode="Forms">
        <forms name="Authen" protection="All" timeout="60" loginUrl="login.aspx"/>
    </authentication>

XML
<authorization>
    <deny users="?"/>
</authorization>


Solution 2 :
You can use following code also
C#
string strPreviousPage = "";
 if (Request.UrlReferrer != null)
   {
    strPreviousPage = Request.UrlReferrer.Segments[Request.UrlReferrer.Segments.Length - 1];
    }
if(strPreviousPage =="")
    {
      Response.Redirect("~/Login.aspx");
     }
 
Share this answer
 
Comments
Dhritirao's 12-Apr-13 23:39pm    
thanku
Dhritirao's 16-Apr-13 0:57am    
if i use this code i m unable to get my master page.

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



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