0

I have developed an application that allows file uploads and downloads with ASP.NET Core Web app (razor pages not controllers). In this app, I am setting a background image on each page as globally it doesn't work but something strange is happening with it.

On Initial login, the homepage background shows fine(see first image), but as soon as you switch to a different page and go back, its like it loses part of its URL? The original URL for the site image on initial login was http://ip.address/PORTAL/hero-range-1.jpg but when switching pages its like it loses the /PORTAL/ part? (see second image)

Before After

4
  • 1
    your path to the image is relative, not absolute. So if your base url, isn't precise, you will not be able to find the image. Notice the URL the image is failing on doesn't include the "portal" tag. On the initial request, that tag is present. Your return or redirect, or whatever action you are using is also using a relative path, for the location of your index file. This is what is causing your issue. Make the path absolute for the image. OR create an API/Use 3rd party host for your images and use url provided by them. Jan 30 at 11:28
  • @MortenBork do you mean instead of background-image: url('hero-range-1.jpg I would use background-image: url("http://ipaddress/PORTAL/hero-range-1.jpg")? Jan 30 at 14:17
  • Have you checked the request url about this image when it load successfully? From your code, i don't find anything unusual. Jan 31 at 7:52
  • @MeganPaterson I would try that yes. Jan 31 at 8:55

1 Answer 1

0
background-image: url('hero-range-1.jpg I would use background-image: url("http://ipaddress/PORTAL/hero-range-1.jpg")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.