开发者

Get the name of the view from inside the view

开发者 https://www.devze.com 2022-12-31 20:11 出处:网络
[HttpGet] public ActionResult LogIn(string username) { if (username == null) return View(\"404\"); return 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

精彩评论

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

关注公众号