Running a .NET 4.5 ASP.NET MVC web app on a .NET 4 server - asp.net-mvc-4

I've just downloaded and installed Visual Studio 11 Beta. I looks great and I was thinking about upgrading some of my website to ASP.NET MVC 4 and .NET 4.5. The question I have is if I can run such a website on a hosting plan that has only .NET 4 installed? Maybe by marking the necessary dependencies as "copy local"? I've search around, but as this beta is fresh from the oven, I couldn't find any helpful data.

I think you should have problems with your hosting. Anyway as many will say using beta for production is not a good idea (although I had done it several times). My suggestion is to switch to some HyperV hosting and install all necessary frameworks there.

i had similar problem,i have visual studio 2012 and my host running for .net 4.0
but my site was .net 4.5
when uploaded and saw the site i got error.
i backed up program.
then went to
C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework
there were 3 folder v3.5 v4.0 v4.5
then i created 2 back up folder one for 4.0 and other for 4.5
from each v4.0 and v4.5 copy these:
1-System.ComponentModel.DataAnnotations.dll
2-System.ComponentModel.DataAnnotations.xml
3-System.Data.Linq.dll
4-System.Data.Linq.xml
now that i had back ups did these:
1-change target framework to 4.0 from project options
2-copied above assemblies from folder v4.5 to v4.0
then build application
everything went well.
good luck.

Related

ASP.NET Core 3.0 not showing on Visual Studio 2019

I want to test the new Blazor server-side framework (aka Razor Components).
I installed Visual Studio 2019 RC, and then the .Net Core 3.0 preview 2, following this official tutorial.
After the install, I only see the ASP.NET Core 2.0 and the 2.1 on the "Create a new ASP.NET Core Web Application" page. The 3.0 is not showing up.
I started to mess around, trying to install other packages from this page, uninstalled and reinstalled Visual Studio 2019, updated to the .NET Core Preview 3, installed several times the x64 and x86 packages in different orders, copy/paste the .Net Core binaries to random folders and so on. Nothing works. The ASP.NET Core 3.0 does not show up.
Here is what my VS looks like when creating a project (the yellow message appeared latter after some messing around with the packages, so it is not the real problem):
Here is the output of the dotnet --list-sdks command:
EDIT
For some reason, I installed the Blazor VSIX package (the WebAssembly - not exactly what I want, but I installed it anyways) and now the ASP.NET Core 3.0 simply shows up. However, just for the blazor templates:
I don't understand. Is there anything obvious I'm missing?
There is an option in Tools -> Options that enables preview versions of the .NET Core SDK. In the VS Preview shipping channel, it is on (by default, and not settable). In the VS Release channel, it defaults to off and you can opt-in.
(Note: it's disabled in the screenshot because I have a Preview build installed.)
The reason for this is to allow you to customize whether a project using a released version of .NET Core (such as 2.1, the current LTS) will use tooling from the newer not-yet-release-quality SDK.
Prior to 16.1, this option was located on the Tools -> Options -> Projects and Solutions -> .NET Core page.
Here is what I did to show .NET Core 3.0 in VS2019
Installed .NET Core 3.0 SDK (No Success)
Restarted VS2019 after installing .NET Core 3.0 SDK (No Success)
Updated VS2019 (Worked Perfectly)
I had the same issue. Here is what worked for me.
First, download the latest .Net Core 3.0 SDK (see 1,2 below).
Next, Check for updates (4,5). (this is what helped me the most)
Next, Enable Preview SDK (5,6,7,8,9) and restart
Now, the .net core 3.0 option should show (11).
It no longer works... again!
The SDK 3.0.100-preview8-013656 doesn't provide the ASP.Net Core 3.0 project template.
You have to uninstall it and install SDK 3.0.100-preview7-012821
https://dotnet.microsoft.com/download/dotnet-core/3.0
I have the same issue here after moving from Visual Studio 2019 Preview to Visual Studio 2019 RC.
This page seems to suggest that you need Preview to use .net Core 3.0 which is annoying.
https://dotnet.microsoft.com/download/dotnet-core/3.0
I looked up the difference between RC and Preview, and they pull builds from different channels (stable and preview).
The next thing I’m going to try is to go back to Preview to see if .Net Core 3.0 becomes visible again.
Tried to get .NET Core 3 (preview 8 in my case) to work in the release version of Visual Studio 2019 but ASP.NET Core 3.0 refused to show up in the "Create new ASP.NET Core web application" dialog.
What eventually worked was to install the Preview version of Visual Studio 2019.
I could have saved a few hours and a lot of hair if I had taken the warning text ".NET Core 3.0 should be used with the latest previews of Visual Studio." (https://dotnet.microsoft.com/download/dotnet-core/3.0) more literally...
In my case is because I did not installed Visual Studio 2019 with that feature. So just create a new project and type .net core. Then click on Install more tools and features:
Then add the following feature:
I had this problem and solved it as follows:
STEP 1: Download .NET Core 3.0
STEP2: Enable the ability to consume preview SDKs by default, As shown below:
I had the very same issue. I tried everything with no success
I already had only x64 version of .NET Core SDK
In addition i had to install x86 version too. That WORKED !!!
If your solution uses global.json and sdk:version isn't compatible with the target framework, it won't let you select it or it disappears from Target framework drop-down in your project's properties. You will need to update it to something like this:
{
"sdk": {
"version": "3.1.0",
"rollForward": "latestMinor"
}
}
I resolved it by installing
dotnet-sdk-3.1.403-win-x86.exe
dotnet-sdk-3.1.403-win-x64.exe
Because the visual studio was taking the SDK from "C:\Program Files (x86)\dotnet\sdk" once you install "dotnet-sdk-3.1.403-win-x86.exe" there will one folder under the above directory. then no need to restart your PC.
https://dotnet.microsoft.com/download/visual-studio-sdks?utm_source=getdotnetsdk&utm_medium=referral
ASP.Net Core 3.0+ just runs on vs2019 version 16.7+.
You need to go to help tab on your visual studio and check for updates and update it to the latest version
Note! (don't use it on your developer machine)
0- make sure you installed .net core 3 sdk. dotnet --list-sdks
1- make sure Tools -> Options that enables preview versions of the .NET Core SDK enabled.
2- uninstall all x86 version of .net core sdk from your machine.
3- restart visual studio and try to create a new project.
I was not able to get .netcore 3.0 preview8 working on my Visual Studio Community Edition (version 16.2.3). I opted to uninstall .netcore 3.0 preview8 and I installed .netcore 3.0 preview7 instead. After insalling .netcore 3.0 preview7 In Visual Studio I checked use previews of the .NET Core SDK option that is in Tools -> Options -> Preview Features and I restarted it. That worked for me, but if someone have .netcore 3.0 preview8 already working, help will be appreciated it.
I've encountered the same problem on a Mac and found a solution to this issue.
On visual studio update tab (Visual Studio -> check for updates) there is a option to change channel to "Preview".
After that you can download necessary updates and go using .net core 3.0
I noticed an interesting behavior. I had the latest version of VS with all the dependencies installed. But when I try to add a new project to the solution, the dialog does not show me the options beyond .Net Core 2.2
But When I create the new project from the startup page, the drop down does show the ASP.NET Core 3.1
So I was able to work around the issue by creating the new project from the startup page, then add the existing project to the solution.
I've had the same issue after installing .net core 3.1. This is how I resolved it.
open powershell, type dotnet --version, it returns '2.2.300'
go to 'programs and features', unistall .net core sdk 2.2.3.0
run dotnet --version again, it returns '3.1.302' and in VS 2019 it shows '.net 3.1'
This answer is for the newest .NET Core version as of 10/11/2020, which is .NET Core 5.0
Specs: VS Version 16.8.0
Target Version of .Net Core: 5.0
You must have version 16.8.0 in order to have .Net Core 5.0
If you still have problems with Visual Studio not showing .Net Core 5.0 in Visual Studio version 16.8.0 (and assuming you downloaded the .NET Core 5.0 SDK for Visual Studio), well, apparently (and correct me if I'm wrong) it is now called just .Net 5.0, omitting the Core.
After selecting .NET 5.0, I was able to install other libraries which are currently version 5.0+ and dependent on .NET Core 5.0+
Is the new name intentional? Anyways, here some evidence of this working (I was able to install the newest version of Newtonsoft and Entity Framework for .Net Core):
Funny enough, when I try to create a new .Net Core project, the version shows up as expected:
I'm very sorry for my English!
[PS: I'm literally copying&pasting this answer, which I answered somewhere else, but given that, when you Google this issue, this stackoverflow question appears first. So thats why I'm reposting]

When updating to .NET Core 1.0 RC2 should "/Program Files/DNX/" be deleted?

These instructions https://www.microsoft.com/net/core#windows indicate that all previous version of .NET Core should be removed from Windows via the Add/Remove Programs before installing .NET Core SDK 1.0 RC2 on Windows.
However after running the uninstall from Add/Remove Programs in Windows 7 and installing .NET Core SDK I see that my /Program Files/DNX/ folder still exits.
This makes me wonder if I should delete it to clean up the system. But perhaps it's needed when working with older projects that were created with RC1 under DNX.
I'd like to know if it's ok to delete the dnx folder and it associated runtimes?
It's up to you. If you leave them there nothing bad will happen because the executables have different names (dnx/dotnet).
You can have dnx and dotnet side by side.
You should not delete this folders if you have old (DNX-based) projects that you still want to run. Otherwise, you will need to reinstall the dnx runtimes again to work with your old (RC1) apps.
Your new (RC2, dotnet cli) projects will known nothing about this old dnx-based folder and will ignore it completely.
Microsoft advise you to remove any old version of .Net Core. The DNX was the runtime and toolset used to build .Net Core and .Net Core apps as per Microsoft. It was consisted of DNVM, DNX and DNU.
With the .Net Core CLI all above (DNVM, DNX and DNU) are part of a single toolset.
You'll may find some issues when removing DNX, also when migrating a existing solution on any beta/rc version of clr or coreclr which were (dnxcore50 or dnx46) and others deprecated now.
NOTE: when uninstalling MS ASP.NET 5 RC1 Update 1 (old version), you
may have issues on your VS 2015 regarding to some projects templates,
existing MVC or WebAPI projects may not load.
I'd suggest you to migrate to .Net Core 1.0 as I did in my side, it was a little pain but you won't go anywhere with a project target to a deprecated version.
You can follow these links to migrate your app:
1) https://chsakell.com/2016/05/21/migrating-asp-net-5-rc1-apps-to-asp-net-core/
2) http://dotnet.github.io/docs/core-concepts/dnx-migration.html

deploying asp.net mvc4 app with EF 5.0

I am pretty new to asp.net mvc development. I have developed an asp.net mvc4 app targeting .NET 4.0 and using EF 5.0 for database connection. Now I want to deploy this app in a Windows 2008 server with IIS 7.5. What are the things I need to make sure that are installed in the server for this application to work properly?
Thanks!
Only two: .NET 4.0 and optionally MVC 4. You can avoid installing MVC 4 if you include binaries in your deployment package.
EF5 you standard .NET 4.0 and for sure you have reference to it, so all needed binaries will be in deployment package
Download MS Web Platform Installer 4.6 if you haven't already on the new Windows 2008 server.
http://www.microsoft.com/web/downloads/platform.aspx
Search for 'Recommended' in the top right search box.
Select and install 'Recommended Server Configuration for Hosting Providers'.
This will install all SQL drivers etc (probably too much in fairness, but in fewer steps) that you need to run .net 4.5 apps, and make it possible to deploy using Web Deploy.
The details of the process can be found in this article
http://www.orcsweb.com/blog/gabe/how-to-install-webdeploy-on-windows-server-2012/

How can you get a .NET 4.5 website to run on IIS6?

I've got an old Windows 2003 server running IIS 6, and I chose .net 4.5 for my latest web app. Problem is I can't get it to run on the server...
.NET 4.0 framework is installed. I've run aspnet_regiis and deployed the website. I gave it it's own application pool. But I'm getting the following error:
The 'targetFramework' attribute in the <compilation> element of the Web.config
file is used only to target version 4.0 and later of the .NET Framework (for
example, '<compilation targetFramework="4.0">'). The 'targetFramework' attribute
currently references a version that is later than the installed version of the
.NET Framework. Specify a valid target version of the .NET Framework, or install
the required version of the .NET Framework.
I saw the requirements for .NET 4.5 as requiring Windows Server 2008 or later, but I'm seeing lots of posts with people just needing to configure the routing for MVC4 so it seems like this should be possible.
So any ideas what I need to do in order for this to work?
EDIT: The strange thing is we are using an ASP.NET Web API site that works just fine... but that should require .net 4.5...
.Net 4.5 cannot be installed on Windows Server 2003.
Instead, you should use MVC 4.0 on .Net 4.0, which will work fine.

Setting up MVC 4 (Razor) with MonoDevelop

I'm trying desperatly to setup a MVC 4 (in the worst caes 3) with Razor on Monodevelop. I'm sitting on a Mac OS X machine, with Mono 2.11.4.
It seems to not have all the assemblies required. System.Web.Helper for instance, doesn't seem to be found. And MonoDevelop can only find System.Web.Mvc version 3 (With NET framework 4.5 selected) or version 2 (with NET Framework 4.0 selected). Does anyone know how to get MVC 4 with Razor to work?
(Razor pages worked with Mono, in theory, with version 2.10.x series, but you had to bundle Microsoft's assemblies with it into your Linux box.)
Since Mono 2.11.1, these assemblies are now bundled by default in Mono, because Microsoft open sourced Razor recently (on March 2012). So: you're using the correct version of Mono.
The catch is that, as explained in this blogpost, MVC4 depends on the async ASP.NET API stack, which is not ready yet in Mono. So yes you can now use Razor with Mono without the need to deploy MS assemblies from Windows, but, you need to stick with MVC3, not 4, for now.
(Copy-pasted my answer from this other stackoverflow question and tweaked it a bit.)
I modified the VS2010 MVC4 Project Template to run out-of-the-zipfile in Xamarin Studio/MonoDevelop on Mac & Linux: http://www.cafe-encounter.net/p1319/run-asp-net-mvc4-on-mono-monodevelop-on-mac-the-c-template-project.
Update: I've done a MVC4 on .Net 4.5 template with notes at http://www.cafe-encounter.net/p1510/asp-net-mvc4-net-framework-version-4-5-c-razor-template-for-mono-on-mac-and-linux including link to github.
According to the Compatibility page on the Mono site MVC4 is supported with the exception of the async features. Unless there is a part of the MVC4 framework that is uses async by default, then those new features will only be a problem if you have added that pattern to your code.