简体   繁体   中英

Asp.Net Core - Returns 500 for no reason

I'd like to ask for help with this weird behaviour.

I have Asp.Net Core (.Net Core version 2.0) application, which runs without problems on my Windows 10 machine, but when I publish it to Debian server, it starts acting weird. I've verified files, the sha1 of application that works on Windows is the same as sha1 of application that acts weird on Debian.

It has multiple controllers with no views - they work without problem (I just return ObjectResult from them). And I have one controller that uses View and whenever I try to call it on Debian server, it returns 500 Internal Server Error without any information - just empty response. I tried uploading debug version to the server, i tried encapsulating the controller methods into try-catch, but everything is still the same -> empty 500 response.

Summary:

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

No error message, try-catch doesn't do anything, debug mode doesn't do anything.

Here is log: https://pastebin.com/22AC8d4G The funny thing is, that I HAVE Form.cshtml in /View/HouseForm : http://prntscr.com/jytj0f - and I tried to put it in /View/Shared as well. It works on Windows, but doesn't work on Debian. Probably .Net Core issue?

If you need any additional information, leave a comment and I'll edit this question.

Ok, here's the problem:

As shown in the log, Asp couldn't find the view file. It worked on Windows, because on Windows, startup path was set one level above the /Views folder. But on Debian, startup path was set two levels above the /Views folder. So I had to add this to Program:

        if (Directory.GetCurrentDirectory().EndsWith("3step"))
            Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "publish"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM