Does ASP MVC3 NEED Webmatrix? - asp.net-mvc

I've just started up on an old project, which was written with MVC2...
Only a small amount of the front end was started, so I decided to use MVC3 and Razor view engine. I created a simple controller and view and went to view the site within Cassini but it just keeps telling me:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'WebMatrix' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 22: using System.Web.WebPages;
Line 23: using System.Web.WebPages.Html;
Line 24: using WebMatrix.Data;
Line 25: using WebMatrix.WebData;
Line 26:
Source File: c:\Users\XXXXXX\AppData\Local\Temp\Temporary ASP.NET Files\root\ecf08653\deea7194\App_Web_index.cshtml.e70a5900.x4np9ici.0.cs Line: 24
As far as im aware WebMatrix is just a bundle of IIS/Sql Server and some other gubbins that im not interested in. I have not explicitly installed WebMatrix (unless it was bundled within MVC3 installer, and even then I cant find it on my harddisk).
Ive gone through my project and removed any and all traces I could find of WebMatrix and cleared the ASP temp files, but it keeps complaining, so im wondering if they have made MVC reliant upon some web matrix functionality?

Razor is part of the WebMatrix package, and MVC 3 is totally dependent on the ASP.NET Web Pages framework. WebMatrix.WebData includes the SimpleMembershipProvider, and is dependent on WebMatrix.Data. What version of MVC3 are you using? Not RC2? If so, see this thread: asp.net MVC webmatrix membershipprovider kicking in

Also if you install the Visual Studio 11 Developer Preview it will kill MVC Razor in your VS2010.
The CTP seems to be the key factor as any version of the Async CTP also kills MVC Razor.
So any MS CTP preview needs to be in a VMWare or PC-VM session as getting back to where you were will tale longer than it did just to install Visual Studio 11 Developer Preview or Async CTP. Seeing that the error is consistent, it seems to be thatanything 4.5 .NET is going to be very different as you move from C# 4.0 to C# 5.0 and Visual Studio 11 is not likely to come out till Nov 2012.

Related

Cannot create a new controller for my new project

So I'm trying to start up a new project following a tutorial.
I'm using visual studio and writing in .net core.
When I try to create a controller i get the following error:
There was an error running the template
C:\Users\dyl.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc\2.1.0\Templates\ControllerGenerator\EmptyController.cshtml:
Template Processing Failed:(4,47): error CS0234: The type or namespace
name 'Hosting' does not exist in the namespace
'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)
This may be a newbie question but I can't seem to find the cause of this problem.
I've tried separately installing the microsoft.aspnetcore.razor package to my project (which is now installed). But that didn't help.
If there is some information missing, please let me know.
The reason is assembly Razor version is for Asp.net Core 2.1 not 2.0, this goes for Design, SqlServer and Web.CodeGeneration.Utils Anything that was marked version 2.1. Either complete the migration from 2.0 to 2.1 or downgrade those 5 assemblies back to Asp.net Core 2.0
Or start over targeting 2.1 with the drop down at the top of the dialog for project creation

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.

Server error in Web Config of VS ASP.NET MVC Solution

I recently inherited am ASP.NET MVC website to hots on my server from a different team within the organization. The solution was built in VS 2012 and I am testing it in VS 2013 before I start hosting on the serer. There were a number of assembly dependency issues that I have fixed - I updated MVC in Nuget and also had to install and earlier version of EF (4.0.0.0) to get the solution to compile.
Now I am faced with another issue in the Web.Config file. The following screenshot presents the issue I am having:
There are only 3 scenarios that I can think of that is causing this which are the following:
1) Something happened when I updated MVC
2) Something happened when installed EF 4.0.0.0
3) The connection string to the old server is still in Web.Config
(the only reason I don't think this is the issue is because the
database it is calling is still in existance and the data is still
there)
I was hoping somebody with more experience with MVC and/or EF could help me troubleshoot this.

Visual Studio 2012 can't resolve namespace even though DLL reference seems fine

I have attempted to create an MVC 5 project by creating an MVC 4 project in Visual Studio 2012 and installing MVC 5 through Nuget.
I can build this fine.
I attempt to add a reference to another DLL, Sitecore.Mvc.DLL, which I can see was built against MVC 5.1.0. The DLL reference is added fine, and there seems to be no .NET framework conflict (which is where I've seen this issue in the past).
I'm trying to add a using statement to my code:-
using Sitecore.Mvc.Presentation;
IntelliSense picks this up fine....even allowing me to auto-complete 'Presentation'.
However when I build I get the following error:-
The type or namespace name 'Sitecore' could not be found (are you missing a using directive or an assembly reference?)
What could be the issue here?
I'm using:-
Visual Studio 2012 - Update 4
MVC 4 Web Application (initially)
MVC 5.1.0 Nuget Package
Sitecore 7.2 - Update 2 (where Sitecore.Mvc.DLL comes from)
.NET 4.5.2 installed on my machine.
Turns out I'm using a different version of Sitecore.Mvc.DLL, which IS targeted to .NET 4.5.1. Seems like the mscorelib reference in Reflector doesn't quite tell all the details.
Now I need to target my Web App to .NET 4.5.1, which means I need to follow the steps here to be able to select it.
http://blogs.msdn.com/b/dotnet/archive/2013/08/08/building-apps-with-the-net-framework-4-5-1-preview-in-visual-studio-2012.aspx
Thanks, and sorry to #Khanh TO, and everyone else for helping out.

After installing MVC3, I can't create or open projects for MVC2 on visual studio 2010

Opening MVC2 Projects just makes "project not supported" error on visual studio, and i can't find the template for creating new projects for mvc2.
I undertand that the mvc2 new project template could be not desired after installing mvc3, but the support for editing and maitaining mvc2 projects should still be there.
in the release notes it states:
ASP.NET MVC 3 can be installed side by
side with ASP.NET MVC 2 on the same
computer, which gives you flexibility
in choosing when to upgrade an ASP.NET
MVC 2 application to ASP.NET MVC 3
I know I have mvc1, mvc2 and mvc3 dlls "side by side" on my GAC, but i'm still hoping this visual studio error is a error in my setup.
If not, ¿Is possible to upgrade the project file and keep all contents the same, pointing to the mvc2 dll?
To answer my own question after a few attempts:
Yes, it is possible to upgrade the project without altering MVC2. Just apply step 8 of the manual migration procedure on the release notes for MVC3:
8- Locate the ProjectTypeGuids element and replace
{F85E285D-A4E0-4152-9332-AB1D724D3325}
with
{E53F8FEA-EAE0-44A6-8774-FFD645390401}.
and reload the project.
This should be all.
The downside is that if other people are working on this project, they will now need to install MVC3 too, in order to get Visual Studio to recognize this new project GUID.

Resources