views:

806

answers:

3

When I use:

System.Environment.Version

The result is "2.0.50727.3053"

I know that 3.5 is compatible and in IIS is identified as 2.0, blah blah...

I would like to know the exact .net version installed and if another resources are installed, like ASP.NET MVC, etc. The problem is that the website is installed in a shared hosting, so I can ask about that resouces to tech support, but if I know programatically, its far better.

Regards

+2  A: 

ASP.NET MVC is not built into Microsoft .NET framework 3.5 SP1.

See this post

I wanted to clear up a bit of confusion I’ve seen around the web about ASP.NET MVC and the .NET Framework 3.5 Service Pack 1. ASP.NET MVC was not released as part of SP1. I repeat, ASP.NET 3.5 SP1 does not include ASP.NET MVC.

What was released with SP1 was the ASP.NET Routing feature, which is in use by both ASP.NET MVC and Dynamic Data.

So there you have it, from the horse's mouth (Haacked again ;).

Robert Harvey
Are you sure about this?I am certain that ASP.NET MVC was a seperate installer that required .NET 3.5 SP1 as a pre-requisite.
Martin Robins
That is not correct. ASP.net URL Routing was baked in, and MVC uses it heavily - but MVC is still a seperate install even if you have 3.5 SP1. See here: http://msdn.microsoft.com/en-us/library/s57a598e.aspx#ASPNETSP1
rifferte
rifferte
+1  A: 

The problem you have is that you are mixing up the compiler/run time version with the framework versions.

Running System.Environment.Version will get you 2.0 - which is true - but that is not what you are looking for.

Are you looking for a one time answer or something to be used over and over? If you truly want to know - upload a sample MVC app and see if it runs. Otherwise you are going to have to programmatically inspect what is installed on the machine you are running on.

rifferte
something to be used over and over... I install a ton of little asp.net websites and it's a nice info to know before install...
Click Ok
+6  A: 

Not sure but try something like this:

bool mvcInstalled = true;

try
{
    System.Reflection.Assembly.ReflectionOnlyLoad(
        "System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35");
}
catch()
{
    mvcInstalled = false;
}

UPDATED:

To know if .NET 3.5 SP1 is installed check for System.Web.Abstractions assembly

eu-ge-ne
I like this solution. This could be really useful in many situations, not just MVC.
Robert Harvey