1

In my session start event how can I know which page or handler triggered the Event?

void Session_Start(object sender, EventArgs e) 
    {
    }
Subin Jacob
  • 4,692
  • 10
  • 37
  • 69

2 Answers2

0

You can use HttpContext.Current.Request.Url for example.

Lanorkin
  • 7,310
  • 2
  • 42
  • 60
  • With ASP.NET MVC this is going to be null, and I forget under what circumstances it can be with WebForms. – Grant Thomas Apr 22 '13 at 11:14
  • In SessionStart we already have HttpContext - so in general case - no, it won't. – Lanorkin Apr 22 '13 at 11:18
  • @GrantThomas See nothing regarding `Request.Current` except it is `evil`; do see about `Session` - but that's not the question here. So you make it interesting to me, but I still don't see when `HttpContext.Current` is null in the `SessionStart`. All I can see is "not unittestable" - but nothing about null.. – Lanorkin Apr 22 '13 at 11:27
  • Maybe not the most definitive reference, just the first I found, and didn't look hard (indeed, didn't have to!) - basically there is variance in the utility of your answer, with no specifics on how and where it can be used, even though those conditions exist. – Grant Thomas Apr 22 '13 at 11:29
  • @GrantThomas Ok. I still don't see use case when `HttpContext.Current` is null in `Session_Start` - and it's really interesting that you are so sure in it. – Lanorkin Apr 22 '13 at 11:32
0

You can use this while creating session:

Path.GetFileName( Request.Url.AbsolutePath )
Gurmeet
  • 3,094
  • 4
  • 19
  • 43