I'm trying to figure out the proper way to write this using Razor syntax:
<div style="background: url(@Url.Content("~/images/@Model.ImageUrl"))">
</div>
I am using @Url.Content("") and need to use a Model property within the string but I can't figure out the proper way to do it.
@ expressions contain normal C# code.
You need to perform ordinary string concatenation:
@Url.Content("~/images/" + Model.ImageUrl))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With