mvc preview 2

Last post 03-28-2008 7:11 PM by tcox. 2 replies.

Sort Posts:

  • mvc preview 2

    03-28-2008, 4:18 PM
    • Loading...
    • coderocks
    • Joined on 04-27-2005, 12:48 PM
    • Posts 4

    Scott Hanslman's demo (Nothwnd) works fine under visual studio , but when hosted as an application under IIS 7 I had problems with image urls.

    <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="ListingByCategory.aspx.cs" Inherits="MyStore.Views.Products.ProductListingByCategory" Title="Untitled Page" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">

    <% foreach (var product in ViewData) { %>

    <% if (product.Category.CategoryName != null) { %>

    <h2> <%=product.Category.CategoryName %></h2>

    <% break; %>

    <%} //end if %><%}//end foreach %>

     

    <ul class="productlist">

     

    <%
    foreach (var product in ViewData) { %>

     

    <li>

    ============================= I tried placing a tilde in front of /Content/Images/... but it was just passed through to the html source. How do form these urls to find the root folder?

    <img src="/Content/Images/<%=product.ProductID%>.jpg" alt="<%=product.ProductName %>" />

    <br/>

    <a href="/Products/Detail/<%=product.ProductID %>"> <%=product.ProductName %> </a>

    <br />

    Price: <%=String.Format("{0:C2}", product.UnitPrice)%>

    <span class="editlink"">

    (<%=Html.ActionLink("Edit", "Edit", new { ID=product.ProductID })%>)

    </span>

     

    </li>

     

    <% } %>

     

    </ul>

     

    </asp:Content>

  • Re: mvc preview 2

    03-28-2008, 6:41 PM
    • Loading...
    • dimi3
    • Joined on 12-13-2007, 5:02 PM
    • Posts 145

    Try either with ../../Content/Images

    or absolute URL as http://YourSite.com/Content/Images. 

  • Re: mvc preview 2

    03-28-2008, 7:11 PM
    • Loading...
    • tcox
    • Joined on 03-28-2008, 7:07 PM
    • Oklahoma
    • Posts 2

    I had the same issue and tried several ways.

    ./Content/Images/ worked for me, with a single dot.

     

    If it's hard to do it right, you have habitually done it wrong.
    Just write the test.
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter