I upgraded an MVC 2 project to MVC 3. How can I set the default view engine to Razor on an existing project?
Edit: Sorry, I was rather unclear. I want to have Razor be the default type in the Add View dialog.
Short answer:
Change in global.asax to use both webforms and razor:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
ViewEngines.Engines.Add(new WebFormViewEngine());
The Add View dialog should default to a Razor selection in the view engine combobox if your project has at least one Razor file already or if it has no Aspx files (i.e. a project with no view files at all). Are you not seeing that behavior?
There is a MVC3 Upgrade tool.
You can find the tool and the tutorial here:
http://blogs.msdn.com/b/marcinon/archive/2011/01/13/mvc-3-project-upgrade-tool.aspx
When you create a new view you can choose the viewengine but i don't know possibilities to set razor like default.
Related
I've been using asp.net mv3 via vs 2010 for quite a while now, also the default views and actions generated when creating a controller are very helpful. However lately, i found it redundant to keep on adding the same stuff in the generate view, for example, i have to place "btn" class names on links and button, since im using a 3rd party css library. So, i was wondering if it was possible to customize the generated views so that i wouldn't have to add them anymore after generation of the view?
image --> http://i.stack.imgur.com/J8Aiz.png
Yes it's possible to customize the built in TT templates which used fot the scaffolding.
Here is a good how to: Modifying the default code generation/scaffolding templates in ASP.NET MVC
If you are more into scaffolding the MVC Scaffolding project could be also interesting for you.
How can I create a MVC3 Razor Label which shows the label text in selected culture(Language)?
I am having get&set culture function and a dropdown list to select the language. I also have a resource file in /Content/Resource folder.
I found a good article which explain how to implement Multilingual in MVC 3 Razor project.
Find the article from the URL
http://www.codeproject.com/KB/aspnet/BilingualMvc3Part1.aspx
Thanks
I recently converted a project to visual studio 2010 then to mvc 3 and now converting views to razor views.
It's all working fine but I notice i cannot get rid of the site.master and replace it with _layout....
Every time, i start the website the default page is always rendered by site.master even tho I see it calling a controller that uses a view that uses the _layout.cshtml
I am wondering if there is at any point anywhere in the file that says the default MasterPage is the site.master ?
Make sure your _ViewStart.cshtml is pointing to the right masterpage.
#{
Layout = "~/Views/Shared/_Layout.cshtml"
}
Beyond that, if site.master is not found in ANY of your code (solution wide search). Try restarting your application.
I have a question. Is it possible to work with AJAX Control Toolkit in razor views?
I need to use TabContainer or similar (it could be a HTML Helper)
I know I can use it in aspx but I'm using Layouts on my project... so maybe a partial view is the solution, I really don't know.
Regards.
I have a question. Is it possible to work with AJAX Control Toolkit in razor views?
Not recommended. The AJAX Control Toolkit consists of server side controls which depend on ViewState and PostBack which are notions that no longer exist in ASP.NET MVC. So referencing the AjaxControlToolkit assembly inside an ASP.NET MVC application is like attaching a caravan on a Lamborghini.
As an alternative you might take a look at jQuery UI which has many useful widgets such as Tabs.
Upon creating a new ASP.NET MVC 3 Razor site, there are 9 Account\*.cshtml files which seem to be views with the controller logic inserted at the top of the view in an anonymous code block. There is no account controller class.
Why is this? As I understood, the benefit of MVC was the separation of concerns of code & presentation. Does this imply that I should remove all of the existing files & re-implement the Authentication & Authorisation layers?
It seems odd that MS would ship the 'worst possible example' with their flagship web framework.
Thanks,
Jarrod
Edit: I was using the wrong entry point within visual studio to create the application (see my comment below). Thanks!
Hmm, something is not quite right on your end.
I just created a new ASP.NET MVC3 Web Application.
I do have a 'Controllers' folder with a proper AccountController as part of the project.
Are you using Visual Studio?
This is incorrect. Here's the default folder structure in the MVC3 Razor starter app:
As you can see, there are two controllers in the ~/Controllers folder.
Just to be clear, I started a new VS2010 instance, created a new MVC3 project, selected "Internet Application" and Razor as the view engine.