What ASP.NET MVC Version

How determine what version of asp.net MVC is being used by an existing MVC Application??

2 Ways for determining ASP.NET MVC Version

1)At design time

2)At Runtime using Code

1)At Design Time

Steps for it

1)In Visual Studio Select Solution Explorer

2)Then Expand References Folder

3)Right click on System.web.MVC assembly

4)Select Properties

Then you get version of MVC

For MVC2 

1)In visual studio select File

2)Then select New

3)Click on project

4)Click on Web

5)Click on MVC2 Web Application

6)Click on OK

7)Then select  No,do not create a Unit Text Project

For MVC3

1)In visual studio select File then New

2)Select on Project

3)Select Web

4)Then select ASP.NET MVC3/MVC4 Web Application

5)Select Empty

6)Select Rajor

7)Select on OK

You get your version.

2)At Run time using code

1)In Visual Studio Select Solution Explorer

2)Then Select Controller

3)In that Select Home Controller

For MVC2

In visual studio write the code like below:

Using System;

using System Collections.Generic;

Using System.Linq;

Using System.Web;

Using System.Web.MVC;

name space MVC2.Application.Controllers

{

[Handle Error]

Public class Home Controller:Controller

public string Index()

{

return typeof(controller).Assembly.GetName().version.To string();

}

}

For MVC3/MVC4

Steps for it

1)In Visual Studio Select Solution Explorer

2)Then Select Controller

3)Click on Add

4)Add new controller

3)And give name Home Controller

In that there is no direct HomeController Option is available for that select Controller Option and add new control and give the name HomeController and click on Add

In visual studio write code like below

Using System;

using System Collections.Generic;

Using System.Linq;

Using System.Web;

Using System.Web.MVC;

name space MVC3/MVC4.Application.Controllers

{

[Handle Error]

Public class Home Controller:Controller

public string Index()

{

return typeof(controller).Assembly.GetName().version.To string();

}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s