views:

33

answers:

1
    [HttpGet]
    public ActionResult LogIn(string username)
    {
        if (username == null)
            return View("404");

        return View();
    }

Inside the view a want to get 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.

+3  A: 

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 %>
Shay Friedman
WoW! what a great solution! :)
stacker
+1 Nice answer! Thanks for showing me something new today. @stacker Sorry I wasn't more helpful.
Bradley Mountford