C# – Master pages — Getting calling page name

asp.netcmaster-pagesvb.net

Can someone tell me how to get the name of the child page being called in a Master page scenario. For example, if I have the following masterpage:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
    <asp:ContentPlaceHolder ID="cphMainContent" runat="server">
    </asp:ContentPlaceHolder>
</body>
</html>

And I create a page called Test.aspx which inherits this masterpage, how can I, from the masterpage, know that Test.aspx has been requested (since this masterpage can be inherited by more then 1 aspx page)?

Best Answer

Going with your comments, I see a couple of options:

1) In your login page, on a non-postback, check the Referrer - this will be the page that sent you to the login page (Request.UrlReferrer), store that in session for the postback of their login details, and then send the user back.

2) Use the standard features of ASP.NET to handle login/redirections (which basically use the same system as 1).

Related Topic