-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Sections within partial views shouldn't fail silently #997
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible to bail out before rendering or is that required to populate _page.SectionWriters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The population of the section writers happens as part of the execution of the page. We could pass in the flag into the IRazorPage and have it throw when you call DefineSection, but it seems like mixing view behavior (full or partial) with page behavior which felt dirty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems fine then. Is there a way for a RazorPage to know whether or not it's a partial?
For our scenarios this seems rather cut and dry. Wondering about 3rd party view engines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't as yet. We could always pass something in - maybe as part of the ViewContext or make it a first class property of IView. The latter might not be a bad idea given that the notion partial and full views exists in the IViewEngine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not a bad idea to know the rendering mode, lets file an issue (low pri IMHO, but we will get to it eventually)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way to optionally define section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, but there's a way to optionally render it if it's defined RenderSection("foo", required: false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracking bug for this #1002
|
|
Fixes aspnet/Razor#79