简体   繁体   English

使用Visual Studio 2017在Azure应用服务中发布ASP.NET应用程序后获取HTTP错误404

[英]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). 我在ASP.NET Framework 4.6.1中有一个应用程序,使用Visual Studio 2017(版本15.7.27703.2035)在我的本地环境中运行时可以正常工作。

On server side, the same application is displaying an HTTP ERROR 404. 在服务器端,同一应用程序正在显示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. 要发布ASP.NET应用程序,我使用Visual Studio的发布工具并在Azure的App Service上部署所有内容。

Visual studio publish tool and project architecture Visual Studio发布工具和项目架构

I tried to use FTP deployment instead of Web Deploy with no success. 我尝试使用FTP部署而不是Web部署,但没有成功。 I also tried manualy with FileZilla with no success. 我也尝试过使用FileZilla但没有成功。

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.. 在服务器端dll我实际上可以访问服务器端的wwwroot文件夹:这意味着我可以访问js,css,图像等。但似乎服务器上不存在控制器,视图和其他文件夹..

  2. Libraries issus? 图书馆的问题? The problem appeared when I subdivided my project with the customs libraries CrmDatabaseManager, SysaidDatabaseManager and UserInterfaceLibrary. 当我使用海关库CrmDatabaseManager,SysaidDatabaseManager和UserInterfaceLibrary细分我的项目时出现问题。

  3. wwwroot inside wwwroot on server side A wwwroot folder include anoter wwwroot folder on the server; wwwroot在服务器端的wwwroot wwwroot文件夹包括服务器上的anoter wwwroot文件夹; 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. 第一个wwwroot文件夹包含所有dll,在其中,还有另一个包含css,js,images等的wwwroot文件夹,但没有控制器或视图的标志。

  4. How I created the project I created the project GPRH this way using ASP.NET Core 2.0 based on .NET Framework 我如何创建项目我使用基于.NET Framework的ASP.NET Core 2.0以这种方式创建了项目GPRH

  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. 当我用库分割项目时,它导致错误404。

To access a file in a libary, you need to do this manipulation first: 要访问库中的文件,首先需要执行此操作:

  1. Right clic on the file > Properties 右侧clic文件> 属性
  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
} 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Visual Studio 2012将具有数据库的ASP.net Web应用程序发布到Azure - Publishing ASP.net web application with database to Azure using Visual Studio 2012 asp.net Web 应用程序模板缺少 Visual Studio 2017 - asp.net web application template is missing visual studio 2017 Visual Studio 2017 15.7.2 - 缺少 ASP.NET Core 应用程序 - Visual Studio 2017 15.7.2 - ASP.NET Core Application is missing Visual Studio 2017从专业版升级到企业版后,ASP.NET应用程序的/ langversion无效选项'7.2' - Invalid option '7.2' for /langversion For ASP.NET Application after Visual Studio 2017 Upgrade from Professional to Enterprise 发布到天蓝色后有关MVC4 asp.net登录应用程序的错误 - Error about a MVC4 asp.net login app after publishing to azure 自定义404错误消息ASP.NET Visual Studio - Custom 404 Error Messages ASP.NET Visual Studio MSB4018错误Visual Studio 2015 ASP.Net和错误将Web应用程序发布到Azure - MSB4018 Error Visual Studio 2015 ASP.Net and Error Publish Web App to Azure Visual Studio社区2017-ASP.Net Web应用程序(.NET Framework)模板已损坏? - Visual Studio Community 2017 - ASP.Net Web Application (.NET Framework) Template broken? visual studio 2017“ ASP.NET Core Web应用程序(.NET Core)”模板丢失 - visual studio 2017 “ASP.NET Core Web Application (.NET Core)” template missing 无法使用Visual Studio 2017将ASP.NET Core Angular项目发布到Azure - Failed to publish ASP.NET Core Angular Project to Azure with Visual Studio 2017
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM