asp.net mvc - Can I make a razor file optionally be a template file (RenderBody or RenderSection) -
when have renderbody
or rendersection
, , try use template directly, gives error:
the file "~/views/home/form.cshtml" cannot requested directly because calls "rendersection" method.
i have form has basic fields, in 1 instance, want extend form more fields (the model inherits original).
maybe should create basic fields in shared file, work if wouldn't throw error above...
in razor, view. "partial views" views don't utilize layout, while more traditional "views" views do. "layout" merely view @ least calls 1 method, renderbody
. rendersection
, likewise layout-specific. making view layout (by calling methods renderbody
, rendersection
, etc., can no longer used "view" or "partial". has way razor handles view processing. time partial being rendered, there's nothing can done renderbody
, razor raises exception.
long , short, can't use layout partial, seems you're trying here. without more information you're trying achieve, it's not possible further that.
Comments
Post a Comment