まず、vs2017でバニラasp.netコア2.0 Webサイトを作成します。その後、私はこれらの行でstartup.csを更新することにより、ノードの開始を追加します。ASP.NETコア2.0でノードを起動するときにエラーが発生する
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のプロセス変数をDevelopmentに追加した後でも、ページを参照しようとするとエラーが発生します。以下のエラーi。
私の2つの質問は次のとおりです。 1.どのようにしてより良いエラーが報告されるのですか。 2.ノードをデバッグモードとプロダクションモードの両方でサーバー上で実行するにはどうすればよいですか。
エラー:
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 portal =>あなたのWebアプリケーションを選択=>アプリケーション設定=>アプリケーション設定で開発値を持つASPNETCORE_ENVIRONMENTを追加して、Webアプリケーションをブラウズし、詳細エラーを確認してください。 –
問題を解決しますか? –