在单个Azure网站中使用虚拟目录 [英] using virtual directories in a single azure website

查看:95
本文介绍了在单个Azure网站中使用虚拟目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了答案连贯的到

I've found this answer coherent to this old article but both don't work. Thus I'm here to ask a new solution that works with VS2017. I'll explain more in detail: First time you define a virtual directory (as "/site1" and physical folder "site\site1") and try to publish from VS2017, you receive an error (cannot write into the specified path) and cannot publish. Then if you enter into the console (from portal.azure.com) and manually create the folder under d:\site with "md site1"), the publish process works (and lot of files have been created under the new folder) and finishes with a "1 successful...", BUT when you browse to the new ..../site1 you receive the following error message: "The page cannot be displayed because an internal server error has occurred."

无法在网络上找到任何东西来解决此特定错误(在一个旧文档中,他们说这是由于两个项目(在同一解决方案中)使用了单独的git repos所致,其中一个定位到根文件夹,另一个定位到根文件夹以虚拟目录为目标,但是我不明白为什么在通过VS2017发布时,不同的源代码控制会在生产中造成麻烦)...

Cannot find anything around on the web to solve this specific error (in one old doc they were saying it is due to separate git repos for the 2 projects (in the same solution), one targeting to the root folder and another one targeting the virtual directory, but I cannot understand why different source controls should make troubles in production when publishing through VS2017)...

有人知道如何解决这个问题吗?

Anybody know how to solve this?

根据David Ebbo的要求进行更新: 我认为问题是Azure方面的配置问题(其他文章没有解释定义虚拟目录时必须通过控制台创建物理文件夹)和/或运行时错误(创建物理文件夹时,VS2017的发布过程有效并成功完成.)

UPDATE as requested by David Ebbo: I think the problem is a configuration problem Azure side (the other articles don't explain you have to create a physical folder through console when defining virtual directories) and/or runtime error (when the physical folder is created the publishing process from VS2017 works and it is completed successfully).

以下是了解上下文的更多详细信息: 1)Visual Studio解决方案包含2个项目:一个主项目"(带"Hello world!"的空.NET Core项目),其发布配置文件针对Azure网站的根文件夹,另外一个子项目"(标准MVC Core). NET模板项目(无自定义),其发布配置文件定位到同一Azure站点,并在站点名称"和站点URL"的末尾添加了"/site1". 2)如果我尝试将子项目发布到站点的根文件夹,则一切正常(但是我当然会覆盖主项目"),因此这不是代码/版本问题. 3)通过控制台,我可以看到文件夹d:\ home \ site \ site1包含与主项目d:\ home \ site \ wwwroot中存在的文件相似"的文件.

Here are more details to understand the context: 1) the Visual Studio Solution contains 2 project: one "main project" (empty .NET Core project with "Hello world!") with publish profile targeting the root folder of the Azure website + another "child project" (standard MVC Core.NET template project with no customization) with publish profile targeting the same Azure site with "/site1" added to the tail of "site name" and "site url". 2) If I try to publish the child project to the root folder of the site, everything works fine (but of course I overwrite the "main project"), thus it's not a code/version problem. 3) Going through console, I can see the folder d:\home\site\site1 contains files "similar" to the ones present in d:\home\site\wwwroot for the main project.

推荐答案

首次定义虚拟目录(如"/site1"和物理文件夹"site \ site1")并尝试从VS2017发布时,会收到错误消息(无法写入指定的路径),并且无法发布.

First time you define a virtual directory (as "/site1" and physical folder "site\site1") and try to publish from VS2017, you receive an error (cannot write into the specified path) and cannot publish.

我创建了一个虚拟目录并从VS 2017发布Web应用程序.我无法复制您的问题.这是我的详细步骤.

I create a virtual directory and publish a web application from VS 2017. I can't reproduced your issue. Here are my detail steps.

步骤1.从Azure门户创建虚拟目录.请确保已选中[应用程序]复选框,然后单击[保存]按钮.

Step 1. Create a virtual directory from Azure portal. Please make sure you have checked the [Application] checkbox and clicked the [Save] button.

步骤2.使用VS 2017部署Web应用程序.从VS部署窗口中搜索并选择一个应用程序服务.

Step 2. Deploy a web application using VS 2017. Search and choose an App Service from VS deploy window.

第3步.单击设置按钮以配置虚拟目录.

Step 3. Click settings button to configure the virtual directory.

第4步.根据虚拟目录名称更改站点名称和目标URL.

Step 4. Change the site name and destination URL based on the virtual directory name.

第5步.单击发布"按钮以发布Web应用程序.

Step 5. Click publish button to publish the web application.

发布Web应用程序后,可以从以下URL成功查看Web应用程序.

After publish my web application, I can view the web application successfully from following URL.

http://mysitename.azurewebsites.net/site1

请检查我的步骤与您的步骤之间是否有任何差异.

Please check whether there are any differences between my steps and yours.

当您浏览到新的..../site1时,会出现以下错误消息:由于发生内部服务器错误,因此无法显示该页面."

when you browse to the new ..../site1 you receive the following error message: "The page cannot be displayed because an internal server error has occurred."

如果是由您的Web应用程序引起的,建议您将customErrors模式属性更改为关",以查看详细的错误消息.

If it caused by your web application, I suggest you change customErrors mode property as 'Off' to view detail error message.

<system.web>
    <customErrors mode="Off" />
</system.web>

编辑2017/6/13 10:37

该问题与ASP.NET Core有关.发布ASP.NET Core Web应用程序时,可以重现该问题.

The issue is related to ASP.NET Core. When I publishing a ASP.NET Core web application, I can reproduce the issue.

我们可以从此正式文件.

将应用程序添加到IIS站点的根应用程序时,根应用程序web.config文件应包括该部分,该部分将ASP.NET Core模块添加为该应用程序的处理程序.添加到根应用程序的应用程序不应包含此部分.如果您在子应用程序的web.config文件中重复该部分,则当您尝试浏览该子应用程序时,将收到500.19(内部服务器错误)引用错误的配置文件.

要解决此问题,我们需要在此子目录中编辑web.config文件.我们可以使用kudu控制台来做到这一点.单击web.config文件前面的编辑​​按钮.

To solve this, we need to edit the web.config file in this sub directory. We can do it using kudu console. Click the edit button in front of web.config file.

删除aspNetCore处理程序,然后单击保存.

Remove the aspNetCore handler and click save.

这篇关于在单个Azure网站中使用虚拟目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆