Imagine I have a class in C# called “Bar” that has a public function on it called Foo().
Inside the Foo() function, is there a way for me to to identify where Foo() has been executed from? More precisely I want to find out if Foo() was called from an .aspx file. Like this <% Bar.Foo() %> versus from code behind Bar.Foo().
The reason I ask is that I want the function to behave differently when it is executed inside a .aspx file.
EDIT:
I realize I can use two different functions, I really don’t want to get into the boring details of my problem because it is very difficult to explain, not to mention very long. Just know that it is a unique problem I am wrestling with, and I know I can solve it by being able to identify the source of where it is called.
When you say “behave differently”; I wonder whether checking
HttpContext.Current(after adding a reference toSystem.Web.dll) would be a better idea…Otherwise, you’re into stack-frame parsing territory; not a good idea.
Of course, I’d want the code to do the same job either way, using something like dependency injection to handle the differences…