Asp.net MVC Site.master and Razor Switch - asp.net-mvc-3

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.

Related

Load razor pages with layout without refreshing entire page

I just created a net6.0 Razor Pages project in Visual Studio 2022. I haven't made any changes to it at all.
The layout is the standard file that gets created. Using a nav bar with links to Home/Index and Privacy. I plan on adding a side bar for navigation as well.
All I want to do is, while using _Layout.cshtml, load pages from my nav links (ex: Index, Privacy, etc...) without reloading/refreshing the entire page. I just want to update the main content without reloading everything.
I've been searching online for a few hours and I just can't find what I'm looking for. I'm not sure where to start :(
There is no way without JavaScript. Try SignalR and JavaScript for Razor Pages

DotVVM page inside ASP.NET webForms Site.master

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.

Design View for ASP.NET MVC3 Views

Is there a Design View in ASP.NET MVC3 ?
There is no 'Design' view in MVC, like there is in Forms. However your views are just HTML so you can use any HTML editor, although they will not be able to interpret the Razor syntax.
What most people do is make changes to the HTML, save (you don't have to recompile,) and refresh your browser. Google Chrome has a very help full tool built in (Firebug or something like it.) Just right click on the page and select Inspect Element. This will come in very handy.
Also one thing to think about since you're new to MVC is that you can easily use most any css themes that you can find online to make the site look very different out of the box.

Dev Express MVC Extensions with Razor - Controls Show as Lists

Any DevExpress control I use, just renders a list. I’ve tried all 3 possible syntaxes (listed on the site below) and every time, the control I want to use (TreeView, NavBar, etc.) just renders as a bulleted list. Any ideas why? I’ve checked Google and the DevExpress support center, but I can’t find any issues like this.
DevExpress with razor guide: http://documentation.devexpress.com/#AspNet/CustomDocument9944
I just put this code on my index page to test that DevExpress is working:
#{Html.DevExpress().NavBar(settings => {
settings.Name = "myNavBar";
settings.Groups.Add("Group1").Items.Add("Item1-1");
settings.Groups.Add("Group2").Items.Add("Item2-1");
settings.Groups.FindByText("Group2").Expanded = false;
}).Render();}
When it reaches the page, it just shows a bulleted list:
Group1
Item1-1
Group2
Any ideas what's causing this?
The project I was working on was being rendered inside another project. I just needed to get rid of my project's layout and add using statements to the cshtml pages:
#using DevExpress.Web.Mvc.UI;
#using DevExpress.Web.Mvc;
The only problem I still have, is the scriptlet code gets highlighted red (but it builds/works fine and has intellisense).
It seems that any required DevExpress' entry is not registered within the MasterPage (_Layout.cshtml) / Web.config http://help.devexpress.com/#AspNet/CustomDocument8163. I suggest that you use specially designed Visual Studio Project Templates http://help.devexpress.com/#AspNet/CustomDocument9145 to avoid missing any required DevExpress' entry.

How to make razor the default view engine in existing project

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.

Resources