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

Sections within partial views shouldn't fail silently #79

Closed
javiercn opened this issue Jul 6, 2014 · 1 comment
Closed

Sections within partial views shouldn't fail silently #79

javiercn opened this issue Jul 6, 2014 · 1 comment

Comments

@javiercn
Copy link
Member

javiercn commented Jul 6, 2014

If you define a section in your layout page, that section can only be "filled" from within the main view (Index.cshtml for example). If you try to do

@section mySection{
}

from a partial view, razor will just ignore the section which leads to a lot of confusion as it fails silently (ignores the section). This is specially troubling when you are rendering a non visible element (like a script) in the section.

We could improve the behavior by:

  1. Allowing the section to be rendered anywhere, but enforcing just one render per section name. (If two components try to render the same section we'll fail).
  2. Do not allow to render section within partial views but throw an exception.
  3. Provide a clear warning by using tooling.
@javiercn javiercn self-assigned this Jul 17, 2014
@yishaigalatzer
Copy link
Contributor

Please provide a code sample of how this is being used.

@pranavkm pranavkm assigned pranavkm and unassigned javiercn Aug 13, 2014
@danroth27 danroth27 changed the title sections within partial views shouldn't fail silently Sections within partial views shouldn't fail silently Aug 17, 2014
@danroth27 danroth27 added bug and removed enhancement labels Aug 17, 2014
@danroth27 danroth27 added enhancement and removed bug labels Aug 26, 2014
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