
October 3, 2024 08:37 by
Peter
This article shows how to determine what version of ASP.NET MVC is being used in your existing MVC application.At Runtime

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.
Go to the project in the Solution Explorer.

Expand references.

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

Now you will see the version property.

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
{
// GET: /Home/
public string Index()
{
return "<b>Version of your MVC is: " + typeof(Controller).Assembly.GetName().Version.ToString() + "</b>";
}
}
}
typeof(Controller)
.Assembly
.GetName()
.Version
.ToString()
The preceding line of code provides the version of your MVC.
Output
