Enable Razor for Views - asp.net-mvc

How do I enable razor syntax (??) for my MVC project (New, not existing). I have visual studio 2010 Ultimate, and http://support.microsoft.com/kb/2385361 update. Is there something else I need to install to enable the latest MVC (3??) options?

You just need to install ASP.NET MVC 3. Easiest way is through the Web Platform Installer (WebPI).
http://www.asp.net/mvc/mvc3
This will give you a new ASP.NET MVC 3 Web Application template in File... New... Project... in VS2010. The wizard should default to Razor, though it's selectable in the View engine dropdown on the first (and only) page of the wizard.

You need to install MVC3 from Microsoft Web Platform Installer http://www.microsoft.com/web/downloads/platform.aspx

You need to install asp.net MVC version 3. Razor view engine is the default one then.

Related

Is ASP.NET MVC 5 released or not?

According to Wikipedia - asp.NET MVC 5 was released on 17th October 2013.
However on the ASP Website I can't see where to download the package.
When I try to create a new Project in VS 2013 - I can only choose asp.NET MVC 4.
How can I install MVC 5 ?
In Visual Studio 2013, the MVC project wizard was merged with the ASP.NET Web Application Wizard. When you target .NET 4.5, select the ASP.NET project. You will be presented with a new wizard that will allow you to select a base template and then customize it further by adding support for Web API or MVC. It also allows you to customize the authentication/authorization model you wish to use in your application.
The MVC 4 wizard is still present under the VS 2012 node in the New Project dialog.
Runtime packages for MVC 5, Web API 2, and Web Pages 3 were published to nuget.org, so you can upgrade existing projects.
You can also download a separate installer for Visual Studio 2012 that will allow you to create an MVC 5 and Web API 2 project, albeit empty. Once you have the project created you will be able to add views and controllers using the new scaffolding. The download for the Visual Studio 2012 support can be found at here
Thanks,
Jacques
From the nuget site:
Microsoft ASP.NET MVC 5.0.0
To install Microsoft ASP.NET MVC, run the following command in the Package Manager Console
PM> Install-Package Microsoft.AspNet.Mvc
You can download it directly from this link:
http://www.asp.net/mvc/mvc5
You can find all versions of latest MVC from below nuget
http://www.nuget.org/packages/Microsoft.AspNet.Mvc

How to create a new ASP.NET MVC web-site in Visual Studio?

From asp.net/mvc i downloaded the MVC 3 Installer, and ran it:
When it finished, i loaded Visual Studio and tried to create a "New" Web-site. But there's no option to create an ASP.NET MVC web-site:
i expected to see something like what's shown on the ASP.NET MVC homepage:
There is also a Getting Started tutorial that lists the steps to follow:
Creating Your First Application
You can create applications using either Visual Basic or Visual C# as
the programming language. Select Visual C# on the left and then select
ASP.NET MVC 3 Web Application.
After that didn't work, i also tried:
a web platform installer
another Web Platform Installer (from the MVC3 homepage)
or download the installer here (also from the MVC3 homepage)
Click on File -> New PROJECT (NOT WEBSITE). it should be in your list
Look in your control panel
DO you have -
Click on New Project and Under Visual C#, select the Web Menu Item. In the list of projects you should see a ASP.NET MVC3 Web Application. Thats what you need to use.
Btw - Are you using Visual Studio Express??

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.

ASP.NET MVC 3 Razor Intellisense

Downloaded and installed ASP.NET MVC 3 (final version) and still I do not have intellisense in Razor views? What is wrong?
Install the ReSharper 5.1.2 update and then ASP.NET MVC 3 Razor Intellisense will work again.
ReSharper 5.1.2 doesn’t interfere with Visual Studio IntelliSense in ASP.NET MVC 3 Razor syntax. Earlier ReSharper 5.x builds had certain issues with Razor IntelliSense that are addressed in 5.1.2. Specifically, ReSharper 5.1.2 doesn’t prevent Visual Studio from automatically providing its own IntelliSense in .cshtml and .vbhtml web pages anymore: both code completion and Parameter Info work as expected.
http://blogs.jetbrains.com/dotnet/2011/01/resharper-512-is-released/
If you have R# installed, change the settings to use VS Intellisense instead of R#'s. R# does not have that capability for Razor yet. If you still want to use it you could try hitting the space bar after the period
Are you up to date with service packs. Off the top of my head I think you need Visual Studio Service Pack 1 beta for it to work

Which Version of ASP.net MVC I'm having?

This seems really silly but;
How can I know which version of ASP.net MVC I've on my system. I've tried Help->About in Visual Studio (2008) but its not there.
When you're in the New Project window, look at the installed templates under web. ASP.NET MVC Web Application is 1.0 (and will say so in the description). The same goes for ASP.NET MVC 2.
alt text http://dusda.com/files/projectswindow.png
In the Control Panel > Add/Remove Programs, I see "Microsoft ASP.NET MVC 1.0" on my machine...
I also see the following comment between the project type selection window and the filename box when I go to start a new MVC project:
"A project for creating an application using the ASP.NET MVC framework (1.0) (.NET Framework 3.5)"

Resources