ASP.NET MVC: How to obtain assembly information from HtmlHelper instance?

后端 未结 3 1722
耶瑟儿~
耶瑟儿~ 2021-02-20 04:50

I have an HtmlHelper extension method in an assembly separate from my MVC application assembly. Within the extension method I would like to get the version number of the MVC app

3条回答
  •  长发绾君心
    2021-02-20 05:38

    Just in case anyone comes across this, here is what worked for me (MVC5 VS2013). Enter straight into the view:

    @ViewContext.HttpContext.ApplicationInstance.GetType().BaseType.Assembly.GetName().Version.ToString();
    

提交回复
热议问题