Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

_ViewStart.cshtml not picked up when added to the root of the app #6308

Closed
danroth27 opened this issue May 22, 2017 · 9 comments
Closed

_ViewStart.cshtml not picked up when added to the root of the app #6308

danroth27 opened this issue May 22, 2017 · 9 comments

Comments

@danroth27
Copy link
Member

Looks like I can add _ViewImports.cshtml to the root of my app so it gets shared across my views and pages, but _ViewStart.cshtml only gets picked up by pages when it is under the Pages directory.

@pranavkm
Copy link
Contributor

Side-effect of this #6184. RazorPages are rooted to the /Pages directory which restricts where the _ViewStart.cshtml for it comes from. Changing the root to "/" would work, but would also change all the page routes to include the /Pages prefix

@danroth27
Copy link
Member Author

danroth27 commented May 22, 2017

What's the one-liner to change the root of Razor Pages to the root of the project?
What are the reasons we decide to go with Pages as the default root?

@pranavkm
Copy link
Contributor

1 .AddMvc().WithRazorPagesRoot("/") in your Startup.
2. @rynowak for the second.

@DamianEdwards
Copy link
Member

We decided to make the change to the sub-folder as it seemed more in line with how the rest of MVC structure idioms (folders for Controllers, Views, Models, etc.). We figured we'd get feedback in preview1 and go from there. So far I haven't seen anything convincing me we should change it to the root (which is what I originally started out thinking it should be).

@danroth27
Copy link
Member Author

My only feedback is it adds a step to the getting started demo (creating the directory) and then I hit this issue when trying to share my layout with the MVC views. Not a big enough deal that I would push for changing the default behavior, but I wanted to understand what the downsides were for using the root.

@DamianEdwards
Copy link
Member

We do look for shared files in the idiomatic places by default though, including /Views. How often are shared files put in the project root? It's not what our templates have ever done so I'm not sure why we'd default to that.

@DamianEdwards
Copy link
Member

And as for the getting started demo, if you're starting from empty, then yes, you need to add a pages folder. I don't think that warrants changing the default though given apps tend to have many more files that benefit from a little organization​ which is inline with our other defaults.

@rynowak
Copy link
Member

rynowak commented May 30, 2017

@danroth27 says that _ViewImports works but _ViewStart does not, so we have something to do here

@rynowak rynowak added this to the 2.0.0-preview3 milestone May 30, 2017
@DamianEdwards
Copy link
Member

If it's split then for sure, this should be fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants