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

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • GDPR Compliance With .NET: Securing Data the Right Way
  • How to Enhance the Performance of .NET Core Applications for Large Responses
  • Zero to AI Hero, Part 3: Unleashing the Power of Agents in Semantic Kernel
  • Developing Minimal APIs Quickly With Open Source ASP.NET Core

Trending

  • Measuring the Impact of AI on Software Engineering Productivity
  • Understanding IEEE 802.11(Wi-Fi) Encryption and Authentication: Write Your Own Custom Packet Sniffer
  • Agentic AI for Automated Application Security and Vulnerability Management
  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  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.3K 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

  • GDPR Compliance With .NET: Securing Data the Right Way
  • How to Enhance the Performance of .NET Core Applications for Large Responses
  • Zero to AI Hero, Part 3: Unleashing the Power of Agents in Semantic Kernel
  • Developing Minimal APIs Quickly With Open Source ASP.NET Core

Partner Resources

×

Comments

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: