0

Firtsly I use wwwroot to storage images that were uploaded by users and I showed that images like this:

<img src="~/Images/ImageName" />

But I realize that I can access all the images inside wwwroot by url even if I not logged, and if the image change the browser still showing the first image till I clear cache.

Next I create a carpet in the ContentRootPath to storage my images, calling them throgh a controller using:

Stream stream = new FileStream(Path.Combine(_hosting.ContentRootPath, "PrivateFiles\\Images\\Usuarios\\" + imageName),
                    FileMode.Open, FileAccess.Read, FileShare.Read,
                    bufferSize: 4096, useAsync: true);

and works fine in development but when I publish the project to deploy in SmarterAsp the images aren't showing.

4

1 回答 1

0

I've already achieve this calling wwwroot images from a controller to authorize, also I add differents names to images everytime are changed to not cached them.

于 2020-05-16T03:00:03.893 回答