How to concatenate two strings in image source with razor?
问题 I've defined the following variable in razor: @{string imageRoot = "/_media/Images/";} I'd like to use it here: <img src="@imageRoot App1/MyImage.png"/> The problem is the space within the string. This will work but I'd like to keep the trailing slash in the variable instead of in the literal: @{string imageRoot = "/_media/Images";} <img src="@imageRoot/App1/MyImage.png"/> 回答1: Looks a little ugly, but works: @{string imageRoot = "/_media/Images/";} <img src="@Html.Raw(imageRoot)App1/MyImage