Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,
I am doing one shopping cart site by using MVC4 and EF5.When I am binding product list from database, its not coming actual data. I have 7 records so its counting all these records and assigning that values means 1234567 for name field and also price field. And one more error is image. I am running the application directly by pressing f5 the images are loaded properly. But when I am typing the URL http://localhost:18771/Home/Index . Images are not showing. When I inspect that image element its shows me that field to load images. Why I don’t know. I have added my code as well. Please help me out .Plzz..

Here is my view
HTML
<ul class="featured-box">
@foreach(var item in Model)
{
    <li>
        <div class="inner">
            <img src="@Url.Content(item.Image1)" width="180" height="180" alt="Shoes" />
            <span class="span_head"><a href="description.html">@Html.DisplayForModel(item.ProName)</a></span>
             <!--<span class="desc">
                Sandal Style. Heel Height - Low. Orthotic Friendly.
            </span>-->
            <span class="price">$@Html.DisplayForModel(item.Price)</span>
            <!--<span class="desc">Availability: <label class="red-font">In Stock</label></span>-->
            <a href="description.html" class="details-btn">Availability</a>
            <!--<a href="addtocart.html" class="cart-btn fright"><span>Add to Cart</span></a>-->
        </div>
    </li>
}
</ul>

Home controller
C#
public ActionResult Index()
{
    IEnumerable<product> productlist = db.Products.ToList();
    return View(productlist);
}



[Edit member="Tadit"]
Corrected formatting and/or grammatical issues.
Added pre tags.
[/Edit]
Posted
v2
Comments
"that field to load images."

That means the URL is wrong.
SanSkun 24-Oct-14 5:18am    
No....Path is correct but when i am directly running my application means this url http://localhost:18771/ its showing perfect but when i am navigating to same page by typing http://localhost:18771/home/Index its not showing...
And what about the 1st error
[no name] 24-Oct-14 5:57am    
Please try with the List<Product> and check if you are getting the data correctly.
You have mentioned that the data is not coming properly, and the Imageurl is fetched from the database, then how the image is being shown when you run the application?
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900