【发布时间】:2017-09-30 04:40:01
【问题描述】:
我首先用 vs2017 创建了一个普通的 asp.net core 2.0 网站。然后,我通过使用这些行更新 startup.cs 添加节点:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddNodeServices(options => {
options.LaunchWithDebugging = true;
options.DebuggingPort = 9229;
});
}
我创建了一个返回一些数据的视图,当我在本地运行它时,它可以工作。这是代码:
public async Task<IActionResult> NodeTest([FromServices] INodeServices nodeServices)
{
ViewData["ResultFromNode"] =
await nodeServices.InvokeAsync<string>("NodeSrc/myNodeModule.js");
return View(viewName: "NodeTest");
}
我的myNodeModule.js如下:
module.exports = function (callback) {
var message = 'Hello from Node js script at ' +
new Date().toString() + ' process.versions ' +
process.version;
callback(/* error */ null, message);
};
当我使用 vs2017 在本地运行它时,它可以工作。当我使用 VSTS 并部署时,即使在开发中添加了 ASPNETCORE_ENVIRONMENT 的流程变量后,当我尝试浏览页面时仍然会出错。错误如下。
我的两个问题是: 1. 我怎样才能得到更好的错误报告 2. 如何让node在调试和生产模式下在服务器上运行。
错误:
Error.
An error occurred while processing your request.
Request ID: 0HL87NKEP2GL6:00000002
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.
【问题讨论】:
-
ASPNETCORE_ENVIRONMENT 变量用于运行时,它不影响构建。你能用一个新项目重现这个问题吗?在 OneDrive 上分享详细的构建和发布日志。
-
转到 azure 门户=>选择您的 Web 应用=>应用程序设置=>在应用程序设置中添加具有 Development 值的 ASPNETCORE_ENVIRONMENT,然后浏览您的 Web 应用程序并检查详细错误。
-
问题解决了吗?
标签: azure visual-studio-2017 azure-devops azure-web-app-service azure-pipelines