简体   繁体   中英

Getting HTTP ERROR 404 after publishing ASP.NET application in Azure App Service with Visual Studio 2017

I have an application in ASP.NET Framework 4.6.1 that works fine when running in my local environnent using Visual Studio 2017 (version 15.7.27703.2035).

On server side, the same application is displaying an HTTP ERROR 404.

Screenshot on local environment

Screenshot on server environment

To publish the ASP.NET application, I am using the publish tool of Visual Studio and deploy everything on an App Service of Azure.

Visual studio publish tool and project architecture

I tried to use FTP deployment instead of Web Deploy with no success. I also tried manualy with FileZilla with no success.

Is it possible that some sort of action is needed when publishing a project with custom libraries?


EDIT

What I know:

  1. dlls on server side I actualy have access to the wwwroot folder on server side: this mean I can access js, css, images, etc. But it seems that controllers, views and others folders don't exist on the server..

  2. Libraries issus? The problem appeared when I subdivided my project with the customs libraries CrmDatabaseManager, SysaidDatabaseManager and UserInterfaceLibrary.

  3. wwwroot inside wwwroot on server side A wwwroot folder include anoter wwwroot folder on the server; the first wwwroot folder contains all dlls, and inside it, there is another wwwroot folder containing css, js, images and etc, but no sign of controllers or views.

  4. How I created the project I created the project GPRH this way using ASP.NET Core 2.0 based on .NET Framework

  5. 发布配置
  6. 项目属性

It turns out that split the project with libraries did broke path references.

I was hard coding the path and there were no problems with that into the main project. When I splited the project with libraries, it caused an error 404.

To access a file in a libary, you need to do this manipulation first:

  1. Right clic on the file > Properties
  2. On Build action , choose Always copy the file

Then specifie the path this way on the library:

var buildDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var filePath = buildDir + @"\fileName.json";

using (StreamReader r = new StreamReader(filePath))
{
   // code here
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM