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.
     Solution Explorer
  2. Expand references.
    References
  3. Right-click on "System.Web.Mvc" and select properties.
    System.Web.Mvc
  4. Now you will see the version property.
    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

Output


Similar Articles