Get the name of the view from inside the view
[HttpGet]
public ActionResult LogIn(string username)
{
if (username == null)
return View("404");
return View();
}
Inside the view a want to get开发者_如何学Go the view file name. In this case the action value is always LogIn
. But the actual view is or LogIn
of 404
. I have a master page that need to know the exactly view name.
Assuming you're using the default WebFormViewEngine, you can use the next statement to receive the view path (including its name of course):
<%=(ViewContext.View as WebFormView).ViewPath %>
精彩评论