This project is read-only.

Which Layout To Load???

Oct 2, 2012 at 5:07 AM

It seems I've come across an issue that I can't get to work as one would expect it to.

I'm attempting to have a web app and a precompiled web app both serving layout files from the _viewstart file. But it seems that only one or the other can be loaded irrespective of the project. It's either the main project (not razorgenerated) or the razorgenerated file if I use PreemptPhysicalFiles = true

I was previously using areas in the external library and that works fine, since it's a completely different path for the library layout file.

Is there a setting? Or, how would you refer to the layout file in the library? I tried using relative paths, but it didn't work.

Oct 2, 2012 at 5:48 AM

Just as a follow-up, I added an area to the library and refer to the layout page in each view (Layout = "...") and it loads as expected. 

Oct 2, 2012 at 6:55 PM

It seems that the issue here is that the main app and the precompiled app cannot share the same structure since they're technically the same. When _ViewStart is checked for the layout it can check the hosting app or the precompiled app, but not both. Same goes for the layout page - if you try to use ~/Views/Shared/_Layout.cshtml, it will pick up either the hosting app or the precompiled app.

The good news is that you can save the layout page in an arbitrary location, like ~/_precompedlayouts_/_Layout.cshtml and as long as there's no match on the host, you're good.

The big hurdle now is how to adjust the _ViewStart for the library otherwise you'd have to assign the layout in each view. Maybe a base page, I'll have to look int it and see if there's way. Any thoughts?

Nov 1, 2012 at 7:58 PM

Just as an FYI - I'm assigning every view a layout in a separate folder that should not conflict with the consuming project.