Where is Html.Image in ASP .NET MVC RC?

前端 未结 6 1765
旧巷少年郎
旧巷少年郎 2020-12-29 06:31

I can\'t find the Html.Image method in new MVC RC version. Please somebody give me example how to render simple Image in ASP .NET MVC RC sites.

6条回答
  •  执笔经年
    2020-12-29 06:41

    If you need to reference an image in, say, the ~/Content/images/ folder, it can easily be done with just plain HTML:

    a picture available anywhere
    

    The trick is the "/" at the beginning of the src attribute, which will tell the browser to start browsing folders at the root of the site. As ASP.NET MVC by default does not parse route urls on files that do exist on the server, the file will be retrieved as usual. This will also work on the Index view of the Home controller regardless of whether you have the url http://www.example.com/, http://www.example.com/Home or http://www.example.com/Home/Index

提交回复
热议问题