0

I have a _ViewStart.cshtml in my main view folder with the following code.

@{ Layout = "~/Views/Shared/_Layout.cshtml"; } 

In the View folder of my admin area I have a _ViewStart.cshtml with this code

@{ Layout = Request.IsAjaxRequest() ? null : "~/Areas/Admin/Views/Shared/_Layout.cshtml"; } 

I put a breakpoint on both lines of code, and when I go into the admin area I can see it hits the viewstart in that folder and not the one in the main folder. Even though it hits that code it still only uses the main layout.

5
  • Can you confirm that the contents of admin layout is different from the default one? Your observation of breakpoints are correct. Commented Oct 29, 2012 at 22:36
  • Yes, to make sure I wasn't confusing them I put in big letters, "This is the main layout", and "This is the admin" on their respective layouts. Commented Oct 29, 2012 at 22:47
  • Well, is Request.IsAjaxRequest() null? I'm also a bit confused by your terminology. What's a 'main view folder'? Do you mean not in an area? Commented Oct 29, 2012 at 23:10
  • 1
    Are you certain you don't have a Layout setting in your view? Commented Oct 29, 2012 at 23:13
  • That was it, I was testing before and had a layout setting in the view I was looking at. If you put that as an answer I'll mark it accepted. Commented Oct 29, 2012 at 23:16

1 Answer 1

1

I didn't see it at first, but the specific view I was testing with was specifying the wrong layout, so no matter what I put anywhere else it was overwriting it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.