I am in the process of converting a good sized asp.net 4 site to MVC3 and I am having trouble with the helper functions in razor partial views. So I wanted to try Spark but after using NuGet to install Spark in my project I don't see how to create a Spark view.
I am assuming that Razor and Spark will co-exist in the same project? If that is not true, then that is probably my problem.
When I treid to create a new view I expected to see Spark in the View Engine drop down on the Add View dialog. Only razor and aspx show up.
I have restarted vs2010 several times now and I shouldn't need to reboot.
Any suggestions?
Take a look at the following blog post.
Related
I have an existing ASP.NET webForms web site project. I would like to use dotvvm in one page of the website. I have successfully created and placed a sample content page .dothtml inside dotvvm master page .dotmaster but is there any way I can place it inside my website Site.master?
I have tried to use the Site.master as master page like that:
#masterPage Site.master
but it gives me an error message because Site.master doesn't have #viewModel line at top of it.
I am working with visual studio 2015 community version with 4.5.2 .NET framework
Unfortunately, DotVVM doesn't have this level of integration yet.
If you want to combine ASP.NET Web Forms and DotVVM pages in one application, you need to create a DotVVM master page which uses the same layout and CSS.
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.
I would like to make custom editor templates for different data types in ASP.NET MVC (to use with Html.EditorFor()), including rewriting the existing templates. The ultimate goal is to create a mini-framework where each editor supports javascript notifications about being changed, and I can show a message to the user that there are unsaved changes in the page. (Maybe there's something existing already?)
I can find many questions pertaining to problems with such templates, but nowhere can I find a tutorial or manual on creating them. Where do they go? Is there any special syntax? How does a template get selected? What information is available in the template and how do I access it? Etc.
So - where can I find out all about these templates?
Check and download ASP.NET MVC 3 Futures on http://aspnet.codeplex.com/releases/view/58781 and see how the default source code looks. Note: this works for MVC 4 as well.
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.
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.