1

On my MVC project I have a form on the Footer within the Layout page, I have to know on which page this form was submitted.

For example: for this URL:

http://www.test.com/myWebSite.test/home

I need the home part.

I tried that:

Path.GetFileName(Request.Url.AbsolutePath);

But I'm getting the name of the Action, for ex:

SubmitForm

I am not sure how to do it, any idea?

user3378165
  • 6,546
  • 17
  • 62
  • 101

1 Answers1

2

If you want to get the current action name or controller name try this:

string actionName = this.ControllerContext.RouteData.Values["action"].ToString();
string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
maccettura
  • 10,514
  • 3
  • 28
  • 35