0

I have an ASP .NET MVC3 (razor) site following this structure:

Site1
    -Areas
        -Area1
            -Views
                -SomeFeature
                    -Index.cshtml --> sets the section 'pageScripts'
                -Shared
                    -_Layout.cshtml --> has Layout = ~/Views/Shared_Layout.cshtml, sets the section 'layoutScripts'

            -Viewstart.cshtml ---> has Layout = ~/Areas/Area1/Views/Shared/_Layout.cshtml

        -Area2
            -Views
                -Shared
    -Views
        -Shared
            -_Layout.cshtml ---> has optional sections pageScripts, layoutScripts

Here's my problem:

When I try to access the equivalient controller method for ~/Area1/SomeFeature/Index, I get an exception message saying

The following sections have been defined but have not been rendered for the layout page "~/Areas/Area1/Views/Shared/_Layout.cshtml": "pageScripts".

I have the section "pageScripts" defined as

@RenderSection("pageScripts", false) in ~/Views/Shared_Layout.cshtml

Why I'm trying to do this:

At the moment, I find myself having to set the Layout property in each view in Area1 (and Area2) to ~/Views/Shared/_Layout.cshtml

Does any one know what I'm doing wrong?

-Thanks for any suggestions

Yasser Shaikh
  • 46,934
  • 46
  • 204
  • 281
abjbhat
  • 999
  • 3
  • 13
  • 24

1 Answers1

0

just a shot in the dark.

1.) Make sure you're using _ViewStart, the underscore is needed ;).

2.) Ensure that the _ViewStart is in the Views folder in the Area, and not in the Area1 folder. At least that's the way it looks in your depiction.

Hope one of those suggestions does the trick. I use similar techniques and works just fine.

Cheers,

Eddy

Dax70
  • 1,051
  • 1
  • 8
  • 16