Asp.Net Core-无故返回500

时间:2018-06-24 17:26:21

标签: c# asp.net-core .net-core asp.net-core-mvc

我想寻求这种奇怪行为的帮助。

我有Asp.Net Core(.Net Core版本2.0)应用程序,该应用程序在Windows 10机器上运行没有问题,但是当我将其发布到Debian服务器时,它开始表现异常。我已经验证了文件,可以在Windows上运行的应用程序sha1与在Debian上运行异常的应用程序sha1相同。

它有多个没有视图的控制器-它们可以正常工作(我只是从中返回ObjectResult)。我有一个使用View的控制器,每当我尝试在Debian服务器上调用它时,它都会返回500 Internal Server Error,而没有任何信息-只是空响应。我尝试将调试版本上传到服务器,尝试将控制器方法封装到try-catch中,但是一切仍然相同->空500响应。

摘要:

+------------+----------+----------+
|            | Windows  | Debian   |
+------------+----------+----------+
| Controller | OK       | OK       |
| w/o view   |          |          |
|            |          |          |
| Controller | OK       | 500 Err  |
| with view  |          |          |
+------------+----------+----------+

没有错误消息,try-catch不执行任何操作,调试模式不执行任何操作。

这是日志:https://pastebin.com/22AC8d4G 有趣的是,我在/ View / HouseForm中有Form.cshtml:http://prntscr.com/jytj0f-我也尝试将其放在/ View / Shared中。它适用于Windows,但不适用于Debian。可能是.Net Core问题?

如果您需要任何其他信息,请发表评论,我将编辑此问题。

1 个答案:

答案 0 :(得分:0)

好,这是问题所在

如日志中所示,Asp找不到视图文件。它在Windows上有效,因为在Windows上,启动路径设置为/ Views文件夹上方的一级。但是在Debian上,启动路径在/ Views文件夹上方设置了两个级别。所以我不得不将其添加到程序中:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Injector } from '@angular/core';

import { createCustomElement } from '@angular/elements';

import { AppComponent } from './app.component';

@NgModule({
   entryComponents: [
      AppComponent
   ],
   declarations: [
      AppComponent
   ],
   imports: [
      BrowserModule
   ],
   providers: []
})
export class AppModule {
   constructor(private injector: Injector) {
      const firstComponent = createCustomElement(AppComponent, { injector });
      customElements.define('name-of-your-component', firstComponent);
   }

   ngDoBootstrap() {}
}