DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Reduce Frontend Complexity in ASP.NET Razor Pages Using HTMX
  • Design Automation in Closure Engineering: Building Parametric Assemblies With CATIA and VB Scripting
  • The Hidden World of Exit Codes: Tiny Integers With Big Meanings
  • GDPR Compliance With .NET: Securing Data the Right Way

Trending

  • Why Stable RAG Answers Can Still Hide Unstable Evidence
  • Google Cloud AI Agents With Gemini 3: Building Multi-Agent Systems That Actually Work
  • Retesting Best Practices for Agile Teams: A Quick Guide to Bug Fix Verification
  • AI Paradigm Shift: Analytics Without SQL
  1. DZone
  2. Coding
  3. Frameworks
  4. Identify ASP.NET MVC Assembly Version

Identify ASP.NET MVC Assembly Version

In this post, we'll learn to check our ASP.NET MVC version installed in our system using C# during runtime and manually customize an error page in ASP.NET/ ASP.NET MVC 5.

By 
Satyaprakash Samantaray user avatar
Satyaprakash Samantaray
·
Jun. 12, 18 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
15.7K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction:

The MVC  pattern separates an application into three main parts.

  1. The Model − Collection of classes that are working with the business logic.
  2. The View − It is responsible for the User Interface. It is an HTML format whose extension is .cshtml.
  3. The Controller − Collection of classes that are working data logic and business logic.

Description:

Every MVC application contains 3 folders: Controller, View, and Model.

Every controller contains controller action methods which are responsible for creating the view to transferring data from the controller to view through ViewData, ViewBag, and TempData.

Every model contains some properties and by using this model class name reference while using namespaces inside a controller we can access related properties of classes for business logic implementation.

In the case of the entity data model creation, an edmx file automatically creates a model class based on the table name or related database object name and with properties related to the column name of that table.

The Way to Find Assembly Version Without Using Code, Called Design Time

In the solution explorer, expand the "References" folder. Right-click on the System.Web.Mvc assembly and select "Properties" to can find the version.

Steps to Be Followed at Runtime Using Code:

Step 1:

Create a controller named “Home.”

Add the code given below in HomeController.cs for better results, as expected. 

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.Mvc;  
namespace Mvc_Version.Controllers {  
    public class HomeController: Controller {  
        //  
        // GET: /Home/  
        public string Version() {  
            return "<h2>The Installed Mvc Version In your System Is : " + typeof(Controller).Assembly.GetName().Version.ToString() + "</h2>";  
        }  
    }  
}  

Code Description:

We mentioned the controller action method version in HomeController.cs.

For this, we should change the action method name in RouteConfig.cs for better loading of the page. For the first time, we will make it a start page.

Add the highlighted code in your file, RouteConfig.cs. 

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    using System.Web.Mvc;  
    using System.Web.Routing;  
    namespace Mvc_Version {  
        public class RouteConfig {  
            public static void RegisterRoutes(RouteCollection routes) {  
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");  
                routes.MapRoute(name: "Default", url: "{controller}/{action}/{id}", defaults: new {  
                    controller = "Home", action = "Version", id = UrlParameter.Optional  
                });  
            }  
        }  
    }   

Output

The expected output is shown below.

http://localhost:49952/Home/Version

Home - Controller name

Version - Controller action method

Image title

Summary:

  • Installed ASP.NET MVC Assembly Version using C#

ASP.NET MVC ASP.NET Assembly (CLI)

Opinions expressed by DZone contributors are their own.

Related

  • Reduce Frontend Complexity in ASP.NET Razor Pages Using HTMX
  • Design Automation in Closure Engineering: Building Parametric Assemblies With CATIA and VB Scripting
  • The Hidden World of Exit Codes: Tiny Integers With Big Meanings
  • GDPR Compliance With .NET: Securing Data the Right Way

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook