0

When I publish my website in the public.html folder the website doesn't open. I get a "forbidden" error. Is it because the project is published with .cshtml extensions? Or is it something else.

My website doesn't have an index page, I changed the startup in Visual Studio so it opens the Home.cshtml page as the standard page. I use Visual Studio 2022 and ASP.NET, not Visual Studio Code. But I use VS Code to upload the website to the FTP server. this is what the project looks like: project and this is what the host server structure looks like: host server

When I change the .cshtml to html, the server is able to read the file and then it works but not all the pages work for example: the layout html in the shared folder doesn't work. Also I don't think it's logic you have to change the extensions to .html instead of .cshtml. When I started my project in Visual Studio, everything worked fine.

  • 3
    you should never switch cshtml into html, asp.net runtime does that for you. it is hard to suggest anything because you have not shared your project structure, project code and the details of the error. "forbidden" can mean anything - under windows it means that the app has no access to the website files. which server do you use? IIS, Kestrel, Azure Web App? you can't run asp.net without server – Yehor Androsov Aug 16 '23 at 16:31
  • Project files look good, it means you are running ASP.NET on .NET Framework. that eliminates some of the options. Do you know if you use any server? FTP upload must upload files into the directory that is observed by server. In IIS, it is called wwwroot – Yehor Androsov Aug 16 '23 at 16:59
  • I need to upload the website trough FTP to the host server in the folder public.html, im connected to the server on VS Code is this usefull or do i need to use iis? if so can i connect to my server on iis or is this not possible? – Jordi Schoetens Aug 16 '23 at 18:01
  • could you show with a screenshot how folder structure looks like on the host server? – Yehor Androsov Aug 16 '23 at 18:20
  • I added it to the main text, hope this helps. – Jordi Schoetens Aug 16 '23 at 18:27
  • Unfortunately, it does not look like a IIS folder stucture. From this url - https://10web.io/glossary/public-html/ - public_html and private_html makes me think it is Apache or something else. I am not familiar with them but I can say that you can't run a .NET application in such environment. – Yehor Androsov Aug 16 '23 at 18:31
  • you can either look into building your website in something like Wordpress or PHP, or look for hosting that allows ASP.NET hosting – Yehor Androsov Aug 16 '23 at 18:35
  • 1
    I will contact the hosting company to see if they can host asp.net. thanks for the help! – Jordi Schoetens Aug 16 '23 at 18:38
  • @JordiSchoetens If you see forbidden error message, it is because you haven't setup your default page correctly. But the important thing that you need to make sure that your hosting provider support for asp.net. If not, you must find .net hosting like Asphostportal or Azure. – TheGunners Aug 25 '23 at 02:58

0 Answers0