AspNetZero - .NET Core 2.0 MVC Version - Error on adding new controller - asp.net-mvc

After about 6 months, I returned to work on my AspNetZero solution based on .NET Core 2.0.
I have the original downloaded version and the modified version as separate GIT repositories. In both versions/repositories when I try to add a new MVC controller, I keep getting the below error message.
On my PC I have all of the .NET Core SDKs installed from 1.0 right up to 2.1.302. I have other projects that I am working on, where I'm using .NET Core 2.1.
I even created a brand new .NET Core 2.0 project in VS2017 and I am able to scaffold a new MVC controller without any errors. This issue is only happening on the AspNetZero solution.
I have done many searches for a solution and none of the answers I found online have worked. I just added a global.json file into my solution folder and set the SDK to 2.0.0 and tried again, still does not work. I keep getting the same error!

Your NuGet packages may have been invalid according to your
target framework. Check all your recent NuGet packages for .NET Core
versions.
Clear your NuGet cache as shown in the picture
Update: Delete all bin & obj folders.

Related

The name 'Url' does not exist in the current context error VS2017

Getting an error The name 'Url' does not exist in the current context error in asp.net whenever I open a .cshtml file in my web project.
I should note that I got this solution fresh from our source repo and other developers tell me they don't see this issue.
Web project has a referenced to a nuget package and when I look at System.Web.MVC it's Mvc.4.0.40804
Things I've tried based on posted solutions:
1) Unloaded project and deleted .user file and did a clean and rebuilt.
2) Deleted temp ASP files in the .net framework directory.
There are a lot of other solutions saying to move views or adding to web.config file, but if other developers using same solution aren't facing this - I'm thinking it's machine specific.
I don't see any reference errors in the web project.
When I installed VS2017, I just did the ASP.NET development. So, i have no gotten another version of MVC. Could it be that?
Thanks,
Brian
So I ended up modifying my VS2017 install and under ASP.NET and web development, I uninstalled that and reinstalled and made sure ASP.NET MVC 4 was checked off under Optional.

Asp.Net 5 Music Store Application

I just did a fresh clone of the Asp.Net music store on github. I understand it is using the new Microsoft.AspNetCore.* libraries as well as the EntityFrameworkCore.* libraries so I have feeds for the RC2 configured in VS. When I load the application for the first time and it restores the packages, I always get this error:
NU1002 The dependency Microsoft.AspNetCore.Mvc 1.0.0-rc2-16991 in
project MusicStore does not support framework
DNXCore,Version=v5.0. MusicStore C:\Users\kyle.36TECHNOLOGY\Documents\Visual
Studio 2015\Projects\MusicStore-dev\src\MusicStore\project.json
Just to troubleshoot, I've moved that dependency in my project.json file out of 'dnxcore50' and into 'dnx451'. The error does go away for my project.json reference, but I get 400 errors, because all MVC seems to break?
rc2 is not stable yet. Try to download the rc1 version https://github.com/aspnet/MusicStore/releases

VS2015 ASP.NET MVC the name 'model' does not exist in the current context

I was working on an ASP.NET MVC 4 in VS2013 and everything was fine, then I've uninstalled 2013 and installed 2015, I was able to open the project, build it and even run, everything works fine (run/debug). The problem is that all my views are covered in errors:
the name 'model\Scripts\Url...' does not exist in the current context
In addition, the .Where method of a list in the model shows an error as well as all the #Html helpers. I want to emphasize that the project still works w\o any problems so the issue is UI or package related. I tried to force uninstall\upgrade Microsoft.AspNet.MVC but the package manager console throws an error and rolls back the attempt. I can provide any necessary info if it helps, thank you in advance.
The newly released VS2015 IDE seems to no longer support MVC3/MVC4 projects, while it only supports the MVC5:
Unable to find MVC3 , MVC4, MVC5 projects (or) No information about supported MVC Framework versions
If there are strict requirements to convert any existing MVC3/4 solution to MVC5 (for VS 2015), you can proceed with the steps listed in the
How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2 guide.
Update 2016-05-03
It seems that after installing the VS 2015 SP2 update, it behaves much better. If you have a chance, I suggest that you upgrade your IDE and check if the issue goes away.

Adding Sitecore 7.5 to existing solution

I am trying to add the Sitecore as a separate project to an existing .Net MVC project which is built in .net framework 4.5.1.I followed the below steps to do so.
Copied Images,Assets,Scripts,Fonts folders from the existing Sample.Web project in to the sitecore project (now the sitecore project is the startup project instead of Sample.Web)
Added reference of Sample.Web to the sitecore project
Copied Views Folder as well because Sample.Web is using MVC
Merged Packages.Config file from Sample.Web Project to the packages .config that we get from Sitecore.
Merged the Web.Config file to the one present in sitecore project
I upgraded the sitecore project to target framework 4.5.1 as the existing projects were using Framework 4.5.1 using the extension https://visualstudiogallery.msdn.microsoft.com/47bded90-80d8-42af-bc35-4736fdd8cd13
Now in the above steps please suggest me on the below:
Will there be any issue in upgrading Sitecore Project to 4.5.1?
Solution is building successfully however I get the below run time error
My guess is your solution uses a more recent version of System.Web.Http than Sitecore does. Some Sitecore code is trying to load the older version of the DLL which you have most likely overwritten with the newer version, thus the exception.
If my guess is correct, I would suggest you rework your solution to use the same assemblies as Sitecore.

Upgrade from .NET 4.5 MVC 4 to .NET 4.5.2 MVC 5.2

Almost the same scenario as before but this time I need to upgrade an app from .NET 4.5 (MVC 4) to 4.5.2 (MVC 5.2). I'd solved the previous issue by doing it on a Win 8 machine. It didn't work on Win 7.
Now, doing the same procedures (on a Win 8 machine) I have problems again.
I've followed the steps:
Upgraded all projects to Framework 4.5.2.
Checked for the Microsoft.AspNet.WebHelpers to uninstall it and it didn't exist.
Did the Manage NuGet Packages for Solution... step, and upgraded Microsoft.ASPNET MVC to 5.2 and Microsoft.ASPNET Web API to 2.2.
Edited all Web.Config files.
I've tried the Final Steps (Unload Project...) but the GUID was already gone.
The project builds fine but when I run it I get a Server Error page:
Attempt by security transparent method
'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security
critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed.
I've tried all solutions that I found on the Net but no luck.
Is there anything else I need to do it because of the target versions 4.5.2/5.2?
UPDATE 1
Removed WebMatrix.Data and WebMatric.WebData. Now I get 403.14 error. The request hits Global.asax Application_PreRequestHandlerExecute method but it doesn't go into Application_Start.
I've solved it. I use Fluent Validation in the project and didn't update FluentValidation.MVC4 to MVC5.

Resources