Get Version of Your MVC Application

Introduction

This article shows how to determine what version of ASP.NET MVC is being used in your existing MVC application.
 
There are the following two ways to get the version of your MVC application:
  • At design time
  • At runtime
At design time

To get the version of your MVC application at design time use the following procedure.
  1. Go to the project in the Solution Explorer:



  2. Expand references:



  3. Right-click on "System.Web.Mvc" and select properties:



  4. Now you will see the version property:


At Runtime

To get the version of your MVC you can use the following code:
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Mvc;  
  6.   
  7. namespace MVCVersion.Controllers  
  8. {  
  9.     public class HomeController : Controller  
  10.     {  
  11.         //  
  12.         // GET: /Home/  
  13.   
  14.         public string Index()  
  15.         {  
  16.             return "<b>Version of your MVC is: "+typeof(Controller).Assembly.GetName().Version.ToString()+"</b>";  
  17.         }  
  18.   
  19.     }  
  20. }  
typeof(Controller).Assembly.GetName().Version.ToString()
 
The receding line of code provides the version of your MVC.
 
Output
 
 

Up Next
    Ebook Download
    View all
    Learn
    View all
    sourabhsomani.com