I have developed a simple ASP.NET Core MVC web app which has this controller class and this view to show a PDF file:

public class HomeController : Controller
{
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            return View();
        }
}

View:

<html>
<head>
    <title class="text-center"></title>
</head>
<body>
    
    <div class="text-center">
    <a  href="~/file/MYCV.pdf">Click to view my CV</a></div>

</body>
</html>

Now using Filezilla, I upload the files to our Bluehost provider, where the files got added on the root as follows:

enter image description here

but when I access the site, I get this error:

Forbidden

You don't have permission to access this resource.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

3

There are 3 best solutions below

2
Douglas Thomas On

Basically 403 forbidden error message happened when you haven't setup your own default page correctly. You may refer to this post https://dotnetblog.asphostportal.com/how-to-fix-403-forbidden-error-message/

1
AudioBubble On

You need to switch hosting providers. Bluehost does not support ASP.NET on shared servers or VMs. It may be possible if you rent a dedicated server, but it'll probably save you time, energy and stress paying a little more to use Azure or a mid-market cloud provider that's slightly less expense - but has a business model with services and support engineers that fit your needs.

https://cheaperasp.net/bluehost-support-asp-net-ms-sql/

0
Rebin Qadir On

I think you uploaded all project files by FTP in ASP.NET Core you should publish assembly files after run publish command in Visual Studio or by wizard Run this command to generate publish files dotnet publish in the package manager console after that you will find publish folder like this bin\Debug\net6.0\publish now you can use FTP or visual studio to deploy files to the host please follow the below link to more details.

https://learn.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-aspnet-web-app?view=vs-2022&tabs=ftp-ftps

Or

https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-webapp-using-vs?view=aspnetcore-6.0