Where do you store images for asp.net mvc projects and how do you reference them from site.master

前端 未结 5 434
春和景丽
春和景丽 2021-01-30 15:53

I have a new asp.net mvc project and i am trying to figure out the best place to store images and also how i would reference them from site.master (in cases where i have a heade

相关标签:
5条回答
  • 2021-01-30 16:05

    What I generally do is create an "Images" folder inside my Content folder. Where you place your images is really up to you, as long as you are consistent.

    Referencing these images from your Site.Master is the same as if you referenced it from any view:

    <img src="/Content/Images/mylogo.png" />
    

    alt text

    0 讨论(0)
  • 2021-01-30 16:05

    or in mvc2:

    <img src="<%: Url.Content("~/Images2/landingMain/safety.png") %>" alt="safety" />
    
    0 讨论(0)
  • 2021-01-30 16:07
    <img src="@Url.Content("~/Content/Images/logo.png")" />
    

    Using this in a Razor view on MVC 5. Images are stored in /Content/Images.

    0 讨论(0)
  • 2021-01-30 16:18
    <%=Html.Image("~/Content/Images/xxx.png")%>
    

    This resolves from wherever you are in the site hierarchy. Html.Image is a part of the the Microsoft.Web.Mvc futures assembly.

    0 讨论(0)
  • 2021-01-30 16:21

    U must put all your images in Content Folder like :- Content-->Images-->.IMG files and same as style sheet files Content Folder like Content-->.css hence it easily load the images and css otherwise it is not executed in proper manner.

    0 讨论(0)
提交回复
热议问题