Create an Application named MVC version
Look at an example for better reference i.e. RouteConfig.cs
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>";
}
}
}
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 of 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