0

I have a folder structure as follows, please see 1st screenshot.

enter image description here

And this is my code so far.

enter image description here

I want to print the indicated PDF document. It works perfectly on my local development machine, but after uploading of site, it tanks. So I am not building the path correctly for web printing it seems? Thanks Luke

jps
  • 20,041
  • 15
  • 75
  • 79
JakeL
  • 191
  • 1
  • 6
  • 18

1 Answers1

0

As far as I know, if you want to access the wwwroot inside the controller, you could try to use IWebHostEnvironment's WebRootPath.

Codes:

    private readonly ILogger<HomeController> _logger;
    private IWebHostEnvironment Environment;

    public HomeController(ILogger<HomeController> logger, IWebHostEnvironment _environment)
    {
        _logger = logger;
        Environment = _environment;

    }

    public IActionResult Index()
    {

        string contentPath = this.Environment.WebRootPath;

        return View();
    }

Result:

enter image description here

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65