Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Login Class
Login Properties
 DestinationPageUrl Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Login..::.DestinationPageUrl Property

Gets or sets the URL of the page displayed to the user when a login attempt is successful.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Visual Basic (Declaration)
<ThemeableAttribute(False)> _
Public Overridable Property DestinationPageUrl As String
Visual Basic (Usage)
Dim instance As Login
Dim value As String

value = instance.DestinationPageUrl

instance.DestinationPageUrl = value
C#
[ThemeableAttribute(false)]
public virtual string DestinationPageUrl { get; set; }
Visual C++
[ThemeableAttribute(false)]
public:
virtual property String^ DestinationPageUrl {
    String^ get ();
    void set (String^ value);
}
JScript
public function get DestinationPageUrl () : String
public function set DestinationPageUrl (value : String)
ASP.NET
<asp:Login DestinationPageUrl="String" />

Property Value

Type: System..::.String
The URL of the page the user is redirected to when a login attempt is successful. The default is Empty.

The DestinationPageUrl property specifies the page that is displayed when a login attempt is successful.

The default behavior of the Login control is to return the user to the referring page, or to the page defined in the defaultUrl attribute of the forms element in the Web.config file.

The DestinationPageUrl property overrides the default behavior of the Login control, as well as the defaultUrl setting made in the configuration file.

This property cannot be set by themes or style sheet themes. For more information, see ThemeableAttribute and ASP.NET Themes and Skins Overview.

TopicLocation
Walkthrough: Managing Web Site Users with RolesBuilding ASP .NET Web Applications in Visual Studio
Walkthrough: Managing Web Site Users with RolesBuilding Applications with Visual Web Developer
Walkthrough: Managing Web Site Users with RolesBuilding ASP .NET Web Applications in Visual Studio

The following code example sets the DestinationPageUrl property. The Page_Load method is used to attach the URL of the referring page to the URL of the destination page so that the destination page can return the user to the original page if desired.

Visual Basic
<%@ Page Language="VB" autoEventWireup="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
        Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            login1.DestinationPageUrl = _
                String.Format("terms.aspx?{0}", Request.QueryString.ToString())
        End Sub
</script>

<html  >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server" 
                DestinationPageUrl="terms.aspx">
            </asp:Login>
        </form>
    </body>
</html>
C#
<%@ Page Language="C#" autoEventWireup="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
        void PageLoad(Object sender, EventArgs e)
        {
            Login1.DestinationPageUrl = 
                String.Format("terms.aspx?{0}", Request.QueryString.ToString());
        }
</script>

<html  >
    <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
        <form id="form1" runat="server">
            <asp:Login id="Login1" runat="server" 
                DestinationPageUrl="terms.aspx">
            </asp:Login>
        </form>
    </body>
</html>

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Framework may well ignore this property      Daniel B· ... Thomas Lee   |   Edit   |   Show History

You may well find that the Framework ignores DestinationPageUrl and always redirects to the referring page, when the user is successfully authenticated.

To workaround this behavior, add a LoggedIn event handler (using Designer or manually in associated code file), that redirects to DestinationPageUrl, e.g.

protected void Login1_LoggedIn(object sender, EventArgs e)

{

// Manually redirect to DestinationPageUrl as Framework doesn't give property precedence over the

// referring page (ReturnUrl), which it should, according to Login.DestinationPageUrl documentation

Response.Redirect(ResolveClientUrl(Login1.DestinationPageUrl));

}

To hook up the event handler with the control (where you didn't use the Designer to add the event handler) add following attribute to Login tag:

<asp:Login runat="server" ID="Login1" DestinationPageUrl="~/MyPage.aspx" OnLoggedIn="Login1_LoggedIn">

Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker