Azure Web App c# razor new page returns 404 page cannot be found

Viewed 46

I have a long running Net 3.1 Web App using c# with Razor. I recently added a new page .cshtml . On localhost, the new page will appear and operate as expected, however after Web Deploy from Visual Studio, xxxxx.azurewebsites.net , the page in question returns 404. There is no subdirectory, its at wwwroot level.

Reviewing errors in logstream in Azure Portal, it shows the file in question and directory path does not exist. xxx.net:80/newpage

Deployment is to Windows based Webapp service.

1 Answers

You're question is a bit vague. I will try to answer as best as I can.

Assuming the web app is setup properly,

When running locally, if you have the .cshtml file open and in focus, (most of the time and if there is no model where the view is expecting data) Visual Studio will render the html in the browser regardless of anything else.

In the cloud, you need a controller action that is the route to your view. If there is no subdirectory, then your Home controller should do.

Another way in the cloud to render the html apart from everything else is to separate the file as an html file and do some routing and DNS configuration.

Please offer some code example of your specific situation and/or what you have tried so far and I will attempt to help further, if I can.

Related