c# - How to protect slash in asp.net mvc and avoid "Failed to map the path" error? -
i've got razor html in area in asp.net mvc project:
<td> @html.displayfor(x => x.amoaresponsible, model.amoaresponsible ?? string.empty) </td>
everything ok when value of amoaresponsible "lorem ipsum". value "amoaresponsible" contains slash (e. g. "lorem/ipsum") , following error:
failed map path '/areas/dashboard/views/psr/displaytemplates/lorem/ipsum.aspx'.
i have no idea how fix this. can protect "/"
?
your using this overload of @htmldisplayfor()
second parameter templatename
, specifies name of displaytemplate
use render property
if value of amoaresponsible
(say) "lorem", method search /views/yourcontrollername/displaytemplates
folder , search file named lorem.cshtml
or lorem.aspx
, wont exist, searches in /views/shared/displaytemplates
wont exist, uses default displaytemplate
(no exception thrown - wasted processing time)
if value lorem/ipsum start searching in /views/yourcontrollername/lorem/displaytemplates
because folder not exist exception thrown.
i assume under belief model.amoaresponsible ?? string.empty
render 'empty string' if value of model.amoaresponsible null
, helper anyway (i.e. generates no output) remove it. helper should just
@html.displayfor(x => x.amoaresponsible)
Comments
Post a Comment