Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7563753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:44:38+00:00 2026-05-30T13:44:38+00:00

I have an HtmlHelper extension method in an assembly separate from my MVC application

  • 0

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 application assembly. Is this possible?

The calling assembly is the razor view dynamic assembly so that doesn’t help. Is there some object nested within the HtmlHelper that can provide me with the version number of the MVC application assembly? I’ve been exploring the HtmlHelper class documentation but so far haven’t found a solution to my problem.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:44:40+00:00Added an answer on May 30, 2026 at 1:44 pm

    This is a notoriously evil thing – because unfortunately there’s no one specific reliable way to do it.

    Since it’s an MVC application, however, the chances are that it has a Global.asax.cs – therefore it has a locally defined HttpApplication class.

    From within an html helper you can get to this:

    public static string AppVersion(this HtmlHelper html)
    {
      var appInstance = html.ViewContext.HttpContext.ApplicationInstance;
      //given that you should then be able to do 
      var assemblyVersion = appInstance.GetType().BaseType.Assembly.GetName().Version;
      //note the use of the BaseType - see note below
      return assemblyVersion.ToString();
    }
    

    Note

    You might wonder why the code uses the BaseType of the application instance, and not simply the type. That’s because the Global.asax.cs file is the primary type of the MVC application, but then Asp.Net dynamically compiles another HttpApplication type that inherits from that via the Global.asax.

    As I said earlier; this works in most MVC sites because they should all have an application class defined in a Global.asax.cs file by convention (because that’s the way the project is set up).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HtmlHelper extension method that I would like to apply some logic
I have an HtmlHelper extension method that looks like this: public static MvcHtmlString TextBoxWithMaxLengthFor<TModel,
In our ASP.NET MVC project, we have an HtmlHelper extension method to generate a
I have an external compiled assembly with HtmlHelper extension methods. I need to use
I have an HTMLHelper extension method that outputs HTML to Response.Write. How best to
So I am creating a HtmlHelper extension method and I have run into a
I have an extension method for getting a string from resource file in asp.net
I have created an HtmlHelper Extension method which returns an encoded string, I have
I have the following HTMLHelper extension to create a submit button that would work
I have an extension method to HtmlHelper: <%= Html.MyMethod( params )%> It works in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.