简体   繁体   中英

Remove auto added trailing forward slash in asp.net mvc img src

I am trying to load a asp.net mvc 4 page with images in jpg extension as the img src. When requesting the images, it's automatically adding a forward slash to the url parameter resulting in a 400 (bad request) from server. How can I get around this?

Example (x.ImageUrl is definitely a string without the trailing slash):

@foreach (var x in Model.List)
    {
        <tr>
            <td>
                <img src=@x.ImageUrl/></td>
            <td><a href="@x.ItemUrl">@x.Title</a></td>
            <td>@x.Price</td>
        </tr>
    }

In view images are requested like this: http://ecx.images-amazon.com/images/I/51a6DHwbx-L. AA160 .jpg/

通过将@ x.ImageUrl放在引号中,可以正确加载图像而不加斜杠。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM