Dofactory.com
Dofactory.com
 Back to list
Views:   26.2K
Replies:  4
Archived

MVC 3 + Razor + Areas (Cannot call layout page)

Hi Team,

Can any one had experience with MVC 3+ Razor + Areas?
I do not get the layout page when I access Areas view pages.. Can anyone help me in this?
I am good with routing and I can access view page inside Areas but it is not showing the ayout page (Masterpage)

Arul
Arul Kalivarathan, Jul 21, 2011
Reply 1
I added the _ViewStart.cshtml to the areas but the problem it is now causing me is that my page loads twice. So I have index method which gets called initially and populates a grid with a blank object.I also have Index with a parameter that gets called when a button is clicked. When I click the button the Index(int param) gets called but then the _ViewStart also appears to get called and loads the Index() method and clears out my data. If I remove the _Viewstart.cshtml it appears to work but now I have no formatting/layout to my page. I experienced this before and can't remember how I fixed it.

asp.net mvc 4
C#

Thanks
Dennis
Dennis Tucker, Nov 21, 2012
Reply 2
Do as Dan suggests and also add your own _layout.cshtml file.  If you have different Areas that will display content differently, it's good to have one _layout.cshtml for each Area.

Also, if you are using VS 2010, you should definitely make sure you are using the latest Tools Update for Visual Studio.  This changes the "Add" dialogs to include many new features including HTML5 stuff.

I hope this helps.
King Wilder, Jul 24, 2011
Reply 3
Rajesh Pillai, Jul 23, 2011
Reply 4
Arul:

Here is what you need:  Include the _ViewStart.cshtml file in the Views folder for the Area.
In fact, if you have a global layout, you should add this file to each Area.

Hope this helps.
Dan.

 
Dan McMillan, Jul 22, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.