开发者

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 %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜