locked
ASP.NET hosting project does not load css and other image files RRS feed

  • Question

  • User-973886032 posted

    hi guys

    I just deployed a new asp.net core 3.0 project, but it seems most of the files are not loading, e.g. the boostrap, css files and lots of images. (AS the website is all over the place)

    I looked through the project (root solution) and included them in my project. (Deleted the entire solution online and re-published it again and again ) even restarted VS.

    But it did not change the problem

    Here is a browser tools. Any advise ?

    Failed to load resource: the server responded with a status of 404 (Not Found)
    icon_le.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    Basket.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    Upload.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    HB013.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    HB011-1.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    HB034.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    cupid.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    icon_flag.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    heart.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    totb.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    ze.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
     e.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    memories.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    dropdown_menu_samples4_2.png:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
    site.css:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
    giphy.gif:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
    bible.png:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
    site.js:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
    dropdown_menu_samples4_2_2.png:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
    men.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    women.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    Icon_Send_Gift.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
    (index):524 Uncaught TypeError: Cannot read property 'addEventListener' of null
        at (index):524
    /favicon.ico:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
    site.css:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

    Monday, August 26, 2019 9:53 PM

All replies

  • User1724605321 posted

    Hi afrika ,

    Where do you put your images , in wwwroot folder ? Also confirm that IIS enables serving Static Content :

    https://stackoverflow.com/questions/10512053/css-images-js-not-loading-in-iis

    Best Regards,

    Nan Yu

    Tuesday, August 27, 2019 3:07 AM
  • User-973886032 posted

    Yes all those are enabled. unless there is another way to enable things which I havent done

    and in my startup.cs file  I have

      app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(
                       Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot"))
                       ,
                    RequestPath = new PathString("/wwwroot")
                });
    
                app.UseHttpsRedirection();
                app.UseStaticFiles();

    Tuesday, August 27, 2019 7:48 AM
  • User1724605321 posted

    Hi afrika ,

    Could you please show the project structure , and you did't need to set the StaticFileOptions , since it seems you are mapping wwwroot to wwwroot .

    Best Regards,

    Nan Yu

    Wednesday, August 28, 2019 2:13 AM
  • User-973886032 posted

    Hi afrika ,

    Could you please show the project structure , and you did't need to set the StaticFileOptions , since it seems you are mapping wwwroot to wwwroot .

    Best Regards,

    Nan Yu

    I dont understand what you mean, but see this 

    Wednesday, August 28, 2019 7:34 AM
  • User1724605321 posted

    Hi afrika,

    The image is not shown , please provide the project struct and also refer to document :

    https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-3.0

    Best Regards,

    Nan Yu

    Thursday, August 29, 2019 2:17 AM
  • User-973886032 posted

    Is this what you mean ?

    see this 

    Thursday, August 29, 2019 9:58 PM
  • User-973886032 posted

    I finally solved this problem.

    I created a new project and it worked, so I copied my old project into the new and noticed if I used the old layout page for some reason the static files didnt load, but when I used the new layout page which had not got the include/exclude variables, then it worked.

    Saturday, August 31, 2019 6:50 AM