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 Runtime
To get the version of your MVC you can use the following code:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
-
- namespace MVCVersion.Controllers
- {
- public class HomeController : Controller
- {
-
-
-
- public string Index()
- {
- return "<b>Version of your MVC is: "+typeof(Controller).Assembly.GetName().Version.ToString()+"</b>";
- }
-
- }
- }
typeof(Controller).Assembly.GetName().Version.ToString()
The receding line of code provides the version of your MVC.
Output