views:

12

answers:

1

I need to dynamically determine the name of the action I'm in from my controller base class in MVC2 in my OnExecuting handler.

So if the Controller is Foo and the Action is Bar, I want the string "/Foo/Bar".

This seems like it should be pretty simple, but I haven't found anything when I STFW.

I'm hoping either one of you is better at the googles than me, or just knows this off of the top of your head.

Thanks.

+1  A: 

Your filter has access to a filterContext parameter. Take a look at its ActionDescriptor property. You can get the name of the action method, metadata about its parameters, etc. If you want just the raw URL, try filterContext.HttpContext.Request.RawUrl (or some similar property).

Levi