Page view counter

How to get the previous page master page id on de default error page

Last post 06-19-2007 7:24 AM by skynyrd. 2 replies.

Sort Posts:

  • How to get the previous page master page id on de default error page

    06-18-2007, 1:01 PM
    • Loading...
    • skynyrd
    • Joined on 12-15-2006, 9:22 AM
    • Posts 405
    • Points 909

    Hi there,

     I have an error page seted on the web.config file

    <customErrors mode="On" defaultRedirect="ErrorPage.aspx" />

     In this ErrorPage.aspx I need to redirect the user to diferent error pages, depending on the Master Page of the page that generated the error .

    Im trying like this

    Partial Class ErrorPage
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim Url As String = ""
    If Not IsNothing(PreviousPage) Then
        If PreviousPage.Master.MasterPageFile.ToString() = "MPTMG.master" Then
            Url = "ErrorPage1.aspx"
        Else
            Url = "ErrorPage2.aspx"
        End If
    Else
        Url = "Error"    'always enters here
    End If
    Response.Redirect(Url)
    End Sub
    End
    Class

     

    PreviousPage is always nothing ! Even thought the errorpage is called from an error in some other page...

     

    Did someone ever tryied to do something like this ?

     

    Thanks

    L. Skynyrd


    Please, mark as answer when appropriate
  • Re: How to get the previous page master page id on de default error page

    06-18-2007, 2:58 PM
    Answer
    • Loading...
    • kalvagadda
    • Joined on 11-12-2004, 4:20 PM
    • Posts 281
    • Points 1,513

    Hi, 

    previouspage is null because the page where error occured redirected to error page.

    only page A post data to page B then you can access PreviousPage in Page B.

    but from server variable "Referer" you can find name of previous page.

    what you can do is for each master apge write erro event

    Master_Error()

    {

    //Here you can redirect to the page you want to. If you error page is doing more than redirecting then then

    redirect to error.aspx like error.aspx?name=MasterPagename

    then you can use query string value in error.aspx.

    }

     Hope it helps.

    Thanks,

    Kiran

    Don't forget to click "Mark as Answer" on the post that helped you.
  • Re: How to get the previous page master page id on de default error page

    06-19-2007, 7:24 AM
    • Loading...
    • skynyrd
    • Joined on 12-15-2006, 9:22 AM
    • Posts 405
    • Points 909

    Cool solutions. Thanks !

    L. Skynyrd


    Please, mark as answer when appropriate
Page 1 of 1 (3 items)