Bryan
Bryan

Reputation: 3541

Set background image in asp.net core mvc

I have created a folder inside wwwroot, called Media. I'm trying to set a background image with css like this:

<body style='background-image: url("~/Media/background.png")'>

But the background does not appear.

However, if I try to put is as a image it works:

<img src="~/Media/background.png" />

So, how do I handle background images?

Upvotes: 1

Views: 1178

Answers (2)

dekanidze
dekanidze

Reputation: 152

Try the following:

<body style="background-image: url(../Media/background.png)">

Upvotes: 1

Brebber
Brebber

Reputation: 3084

Maybe: try to use url of image instead of relative path.

In That case I suppose `https://yourdomain/media/background.png' could do the trick.

Upvotes: 0

Related Questions