Is it possible to render Razor in Html.Raw()? I have a dynamic page being generated that uses the Html.Raw() method to render the page that is created in the controller. Inside this page I have an image tag that should retrieve the image via Url.Action.
var image = string.Format("<img src=\"@Url.Action(\"GetImage\", \"ImageUtility\")?id={0}\" alt=\"{1}\" />", Image.ImageId, Image.Name);
As you can see this would render the following without the razor being rendered:
<img src="@Url.Action("GetImage", "ImageUtility")?id=10000" alt="Image Name" />
Try wrapping
Url.Actionwith parenthesis.See this answer and @Igor’s comment related to.