0

i want to know that from which pages my current page has been called in ASP.net

As for example

I want the track of page named "hero.aspx" and it has been called from "Zero.aspx"
and "Zero.aspx" has been called from "one.aspx"

So i want output as whole page called hierarchy.

How can i get this in asp.net

4
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by __avd
0

You can use the following code to display the stack trace:

StackTrace ObjStackTrace = new StackTrace();
        StackFrame[] ObjStackFrameArray = ObjStackTrace.GetFrames();

        foreach (StackFrame stackFrame in ObjStackFrameArray)
        {
            Response.Write(stackFrame.GetMethod().Name);
            Response.Write("<br><br>");
        }
0

I'm not sure if the stack trace is really what you are looking for here. While I have not heard of or used anything such tool in asp.net, a suggestion, or idea for a method comes to mind:

Set a session variable in your global.asax on session start that is a list of strings or something the like. Each time a page is loaded, add a new item to the list containing the name of the page being loaded.

It may be a bit more code than you were hoping to use, but it should do the trick.

Hope that helps.

0

StackTrace and StackFrame belongs to System.Diagnostics namespace.

TIP: You can get the namespaces from MSDN

Edited by Knvn: n/a

0

I have not heard of or used anything such tool in asp.net, a suggestion, or idea for a method comes to mind

Why cant we use the tool or libraries?, if it is working fine and satisfies our needs.

Set a session variable in your global.asax on session start that is a list of strings or something the like. Each time a page is loaded, add a new item to the list containing the name of the page being loaded.

I don't think there is any performance advantage to track the method caller like this. If I'm wrong, please advise me.

Edited by Knvn: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.