Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net Razor render concatenated text with no space

Tags:

razor

I have:

 @:<img src="@Url.Content("~/content/images/lesson_icon/")@mi.LessonId .png" />

But it renders as ...lesson_icon/d40d2ff2-d06b-4fd8-80a0-0ed31bbc04eb%20.png

How can I get rid of the %20 in front of .png ?

like image 712
phoenixAZ Avatar asked Oct 29 '25 20:10

phoenixAZ


1 Answers

You have a space before your file extension that you should remove there:

<img src="@Url.Content(string.Format("~/content/images/lesson_icon/{0}.png", mi.LessonId))" />

or if you are using Razor v2 you could try that:

<img src="~/content/images/lesson_icon/@(mi.LessonId).png" />
like image 97
Darin Dimitrov Avatar answered Nov 02 '25 22:11

Darin Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!