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.

Jhorra
  • 6,233
  • 21
  • 69
  • 123
  • Can you confirm that the contents of admin layout is different from the default one? Your observation of breakpoints are correct. –  Oct 29 '12 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. – Jhorra Oct 29 '12 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? – Erik Funkenbusch Oct 29 '12 at 23:10
  • 1
    Are you certain you don't have a Layout setting in your view? – Erik Funkenbusch Oct 29 '12 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. – Jhorra Oct 29 '12 at 23:16

1 Answers1

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.

Jhorra
  • 6,233
  • 21
  • 69
  • 123