Finding out ASP.NET Version a MVC application is running on - asp.net

We Have following MVC project where the build settings are as follows.
Application Build settings
And there we have the statement in the index page
#Html.Raw("Version: " + System.Environment.Version.ToString()); to show the ASP.NET version running.
when the Application is running through Visual studio it displays
My Question is why is it displaying 4.0 where it should be 4.7.2 looks like the application is using ASP.NET 4.0 to me.
Appreciate if someone could explain why we are getting a different runtime displayed here.
If it's the correct version 4.0 what should we do to make IIS express use 4.7.2

As far as I know, the IIS application pool is use CLR version not use .Netframework version.
The CLR is identified by its own version number. The .NET Framework version number is incremented at each release, but the CLR version is not always incremented.
For example, .NET Framework 4, 4.5, and later releases include CLR 4
More details, you could refer to this article.

Related

.Net framework version shown is not correct [duplicate]

This question already has an answer here:
Version Information on ASP.NET Server Error Page
(1 answer)
Closed 3 years ago.
I'm using IIS 8.5, .Net Framework version 4.7.2 installed. My legacy web application target framework is set to 4.7.2. As per my knowledge, it uses .Net CLR version v4.0. But, I'm confused with attached error where it show app is running under .Net Framework Version is 4.0. Please suggest how to validate this, I'm not sure why it is not showing 4.7.2.
4.0 is what you're supposed to see here. There are only 3 total IIS .Net runtimes for ASP.Net: 1.0, 2.0, 4.0. Even in these three, you rarely see 1.0 any more. Also, there is no 3.0 or 3.5 (they really still target 2.0), and Core is separate from IIS.
All the other point versions you may use, such as 4.7.2, resolve to one of those three runtimes within IIS.
Think of it this way: every version of .Net for 4.x has the same set of IL it can use. New point releases may add new features and types, but they still compile down to some set of 4.0-compatible IL. The addition of new types is why you may need to actually install 4.7.2 on the server before your site will run, but it's still IL for the 4.0 runtime.
If you really had a .Net version conflict, you'd see a 500-series HTTP error. This is only a 404. You need to find out why it doesn't see your test.aspx file.

Asp.Net Core 2.1 with .Net Framework 4.6.1 error after deployment using dotnet publish or visual studio publish

I am trying to deploy Asp.Net Core 2.1 application with target framework 4.6.1 on server. I am using dotnet publish command and copying the publish folder on the server where deployment is intended. Everything works fine on local machine. But when I am trying to run the application on the server , it is throwing the exception ".Net Framework 4.6.1 not installed, please install it.".
I thought .Net framework is not installed but when I checked installed software , I can see .Net 4.6.1 is installed. Not sure why the error is occurring.
Here is screenshot for the application error and installed software
That error is odd, since you do indeed seem to have that version installed. However, I believe it may be a red herring. I haven't personally tried to run ASP.NET Core 2.1 on .NET Framework, but I suspect it may not work at the moment. The full framework support depends on .NET Standard compatibility which only goes up to .NET Core 2.0. (With .NET Standard 2.0). ASP.NET Core requires .NET Core 2.1. You can try targeting a later version of .NET Framework - something recent like 4.7.2. You may need to downgrade to ASP.NET Core 2.0, if you need to target .NET Framework.
Your list only shows development packages to support targeting and developing for .NET Framework 4.6.1
See How to: Determine which .NET Framework versions are installed for ways to check the .NET Framework version on the machine.

IIS7 Application Pool 4.5 framework

I built a web app using dotNet 4.5. I went into IIS and created a new app pool but there was not 4.5 option, only 4.0 and 2.0. I went to install 4.5 and it says "already installed". I do a google search and see infact the registry and explorer show it to be installed.
What gives?
Although the .NET Framework Version column shows "v2.0" and "v4.0" for .NET Framework versions, these equate to ASP.NET 3.5 and ASP.NET 4.5.
Due to the internals of how application pools bind to .NET Framework versions, the actual version name written to configuration (and thus displayed in the tool) corresponds to the original .NET Framework file version.
Your question is tagged as IIS7 but the link information regarding .net versions is applicable.
Soruce: http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-using-aspnet-35-and-aspnet-45

Running IIS .NET4 Application under a .NET2 Site

Is it possible to host a .NET 4 application under a .NET 2 site?
For several reasons we have to run the main site on .NET 3.5, but there is an application written in entity framework 4, which hosted under the same domain/port.
When I try to add an application under the site (using a different .net 4.0 application pool), i get an error stating duplicate content in web.config. I have searched the net for fixes, but none of them seems to be working for me.
I am running a Windows Server 2008 R2 with IIS7.5
Any help would be appreciated.
It is possible to fix, if you carefully read Microsoft's document,
http://msdn.microsoft.com/en-us/library/a99txfy5.aspx
and
http://www.asp.net/whitepapers/aspnet4/breaking-changes#0.1__Toc256770150
No, that's not possible. An assembly compiled against .NET 4.0 must be run inside CLR 4.0. It is possible the other way around: run an assembly compiled against .NET 2.0 inside CLR 4.0.
No, the nested application will not be able to set a seperate framework version. I would suggest changing the version on the main site to v4. I don't think you should experience problems running a 3.5 app on version 4. What are your reasons for running it in 3.5?

Debugging .Net 3.5 code running under a .Net 4.0 App Pool

I have trawled the internet - to no avail. Woe is me.
I have a .Net website running under a .Net framework 4.0 App Pool.
The website references various assemblies that have been compiled for .Net 3.5.
I have ensured that identical versions of the dll's and pdb's are in the bin folder of the the 3.5 code that I am trying to debug, and the reference path of the 4.0 web site. I.e. the code that I am trying to debug matched the assemblies that are loaded into the app pool's process.
When I attach the debugger using VS2008 with the solution for the .Net 3.5 code open, the breakpoints that I have set are marked as invalid (i.e. marked with an exclamation mark). When I hit refresh on a browser page that invokes the code that I am trying to debug, VS2008 raises an unmanaged code exception.
I have researched In-Process Side-by-Side code execution, which is what is occurring in this instance, and is working very well; but for the life of me I cannot find any information on debugging in this scenario.
It is not an option to convert the .Net 3.5 projects to use .Net 4.0, nor is it possible to convert them to use VS2010 and leave them targeting .Net framework 3.5
Any help will be greatly appreciated.
When an App Pool targets .NET 4.0 this means that your site runs under the CLR 4.0 and the assemblies compiled against .NET 3.5 are loaded in this CLR. VS2008 cannot debug processes running CLR 4.0, only CLR 2.0.
So if you want to debug either change the AppPool CLR to 2.0 or use VS2010 or even better use the Visual Studio's integrated server which you used to develop this site.

Resources