locked
Resource can not be found RRS feed

  • Question

  • User-605499000 posted

    I was using Microsoft wingtop toys to help me build a product program..  The images are not coming up.  Below is the files that I used. Product that sends me to Category and then to ProductDatabaseInializers  undel the model file.

    Product file

    using System.ComponentModel.DataAnnotations;

    namespace BumplesBM.Models
    {
    public class Product
    {
    [ScaffoldColumn(false)]
    public int ProductID { get; set; }

    [Required, StringLength(100), Display(Name = "Name")]
    public string ProductName { get; set; }

    [Required, StringLength(10000), Display(Name = "Product Description"), DataType(DataType.MultilineText)]
    public string Description { get; set; }

    public string ImagePath { get; set; }  (here is the image path that I am using that must be the problem)

    [Display(Name = "Price")]
    public double? UnitPrice { get; set; }

    public int? CategoryID { get; set; }

    public virtual Category Category { get; set; }

    Category file:

    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;

    namespace BumplesBM.Models
    {
    public class Category
    {
    [ScaffoldColumn(false)]
    public int CategoryID { get; set; }

    [Required, StringLength(100), Display(Name = "Name")]
    public string CategoryName { get; set; }

    [Display(Name = "Product Description")]
    public string Description { get; set; }

    public virtual ICollection<Product> Products { get; set; }  (here it goes to the product file  and says get. should there be an image get?)
    }

    ProductdatabaseInializer file

    using System.Collections.Generic;
    using System.Data.Entity;

    namespace BumplesBM.Models
    {
    public class ProductDatabaseInitializer : DropCreateDatabaseIfModelChanges<ProductContext>
    {
    protected override void Seed(ProductContext context)
    {
    GetCategories().ForEach(c => context.Categories.Add(c));
    GetProducts().ForEach(p => context.Products.Add(p));
    }

    private static List<Category> GetCategories()
    {
    var categories = new List<Category> {
    new Category
    {
    CategoryID = 1,
    CategoryName = "Magazines"

    },
    new Category
    {
    CategoryID = 2,
    CategoryName = "Books"

    },

    };


    return categories;
    }

    private static List<Product> GetProducts()
    {
    var products = new List<Product> {
    new Product
    {
    ProductID = 1,
    ProductName = "Bumples Magazine",
    Description = "Stories, games and facts for kids 6-10. 4 issues + game issues ",
    ImagePath="BumplesMag1.png", (here is the image path again from product that is not opening up the image) 
    UnitPrice = 15.00,
    CategoryID = 1
    },

    the images are in the Category file under images and thumbs.  Everything looks like the files from wingtop and the product site comes up but no images.

    Thanks, Jen
    }
    }

    Tuesday, November 13, 2018 3:42 AM

Answers

  • User-605499000 posted

    Thank you very much for your answers. I found the mistake that I made. I changed catalog to category and of course it did not work. Took a day off yesterday and found the mistake right away.

    But I did read the articles that you told me to go to and I also have learned a lot and I thank you for that.  I am not a real programmer but a writer and publisher but trying to get a new site up since the old site outdated.

    Thank you again for your time.

    Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 15, 2018 5:00 PM

All replies

  • User753101303 posted

    Hi,

    More likely you have to give the exact virtual path for your file ie something such as :

    ImagePath="/images/thumbs/Category/BumplesMag1.png";

    You may want to have a look also at https://msdn.microsoft.com/en-us/library/ms178116.aspx#Specifying Paths for Resources and the "Web application  root operator" (~)

    Tuesday, November 13, 2018 10:04 PM
  • User61956409 posted

    Hi bumples18,

    bumples18

    Everything looks like the files from wingtop and the product site comes up but no images.

    Please use F12 developer tools Network tool to check the response status code of image resource(s), does it indeed return 404?

    the images are in the Category file under images and thumbs. 

    If the response status code of image resource(s) is 404, as PatriceSc methioned, you should modify and specify a correct ImagePath. You can share a screenshot of your project folder structure, so that we can help you correct the ImagePath based on your actual folder structure.

    Note: If the response status code of image resource(s) is 200, please check if any CSS styles applied to the image element and hide the image.

    With Regards,

    Fei Han

    Thursday, November 15, 2018 7:07 AM
  • User-605499000 posted

    Thank you very much for your answers. I found the mistake that I made. I changed catalog to category and of course it did not work. Took a day off yesterday and found the mistake right away.

    But I did read the articles that you told me to go to and I also have learned a lot and I thank you for that.  I am not a real programmer but a writer and publisher but trying to get a new site up since the old site outdated.

    Thank you again for your time.

    Jen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 15, 2018 5:00 PM