Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET WebForms C#4.0
When we copy the url from one browser window to another browser window the page for the specified url address should not be displayed it should be redirected to login page only.
Posted 31-Oct-11 23:53pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

if (clsCommon.getCookieValue(clsCommon.AdminCookiesName.Admin_MUSRID.ToString()) != null)
        {
            if (string.IsNullOrEmpty(clsCommon.getCookieValue(clsCommon.AdminCookiesName.Admin_MUSRID.ToString())))
                Response.Redirect("login.aspx", true);
        }
 
or
 

if ((Session["MCUSXintIde0"] + "") != "")
           {
           }
           else
           {
               Response.Write("<script type=\"text/javascript\">" +
                       "window.parent.location = '" + clsCommon.value("SiteUrl") + "login?loginUrl=' + window.parent.location + '';" +
                               "</script>");
               Response.End();
           }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You must specify the authentication and authorization tags in web.Config files to redirect to a loginpage if the user is anonymous.
 

ASP.NET authentication and authorization[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

use following code
Place this code in ur web.config file
<authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>
login url is the relative address of ur login page.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Use "Asp.Net Session"
 
Have a look at this.
http://msdn.microsoft.com/en-us/library/ms178581.aspx
 
Updated -
This also seems to be useful for your requirement.
ASP.NET Login Controls Overview
  Permalink  
v3
Comments
PGunge at 1-Nov-11 6:13am
   
but what if we are not using any Login controls?
PGunge at 1-Nov-11 6:19am
   
waiting for reply .
(Rais)_(Kazi) at 1-Nov-11 8:00am
   
Those are alternate options, it's depends with which you want to go.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hi ,
 
Use Global Application Class( Global.asax)
 

<%@ Application Language="C#" %>
 
<script runat="server">
 
    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        
 
    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }
 
    void Session_Start(object sender, EventArgs e) 
    {
       
        Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~\\LoginPage.aspx"));
        
        
        
    }
 
    void Session_End(object sender, EventArgs e) 
    {
        
        Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~\\LoginPage.aspx"));
       
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }
       
</script>
 

 

When you copy the url from one browser window to another browser window the page will redirected to login page
 

Regards,
Pal
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 424
1 Nirav Prabtani 298
2 OriginalGriff 199
3 _Amy 165
4 Maciej Los 145
0 OriginalGriff 7,755
1 Sergey Alexandrovich Kryukov 6,951
2 Maciej Los 3,994
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 11 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100