luddep
luddep

Reputation: 249

Cant find views/controller in published Azure app service

I have a ASP.NET Core 2.2 Web site that is now published to my azure App service.

My problem is that when i try to visit my published verision of my site in the browser, I get a 404 for most of the views.

I have 3 different controllers:

All of the controllers have Actions, and the actions that returns a view is named exactly the same as my razor pages in these maps (NOTE: Executioncontroller is just for actions that doesn't return views.):

Image of Home and Admin controllers views

When I created the publish profile I right clicked on the project and choose Publish. Then I created the profile with these settings:

enter image description here

When I later on visited the Index view in the home controller witch is set as the home view everything was working fine, but after som clicking around I realized that some of the views just displays Chrome's default 404 page and says: The site mysite.azurewebsites.net cant be found. After trying to figure it out and a couple of publishes later, i cant even find: https://mysite.azurewebsites.net/Home/Index witch could be found before.

This is the General settings for the app service:

enter image description here

Here is for example the index action in the homecontroller thet returns a view:

enter image description here

And the view with the exact same name can be found in the Views/Home folder:

enter image description here

I enabled advanced logging for my app service and when i visit Home/Index action i get en Exception that says

2020-02-24 18:44:03.709 +00:00 [Error] Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware: An unhandled exception has occurred while executing the request.System.InvalidOperationException: Cannot find compilation library location for package 'Microsoft.AspNet.WebApi.Client'

Is it anybody that have had this problem to and is it someone that knows how to fix it? I have searched a lot but never found someone with the same problem.

Thanks in advance!

Upvotes: 0

Views: 1131

Answers (1)

Fei Han
Fei Han

Reputation: 27793

I suspect that some of the outdated/damaged files exist on web server (your app service), which cause the new publish not working well on your Azure app service.

And as we discussed in comments, making "Remove additional files at destination" option checked for a subsequent deployment to the same site, which would help delete the additional content available at the destination server (normally under app service site\wwwroot folder) that you have deleted in your project.

Upvotes: 1

Related Questions