简体   繁体   中英

.NET CORE APIs and IIS (localhost) Internal server error 500

I have some issue with IIS on Windows 10.

I have 2 .net Core (v 3.1) API projects, simple for test. First API project has controller witch return only string from constant. Second API project has controller and action, which call API from first project and return this value. Nothing else.

When I run both projects from Visual studio as multi project, everything works ok. I tested it by Postman. In postman I call api method from second project, it calls api from first project and return test string. Super. But problem is when I publish both project to ISS. Both projects are working. When I call method from first project it returns corret value. When I call some test method from second project it works. But when I call method from second project which is calling api from first project it faild with Internal server error 500. Only 500, no sub error. I add try catch into api and there is exception like this:

One or more errors occurred. (The SSL connection could not be established, see inner exception.)The SSL connection could not be established, see inner exception. at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task 1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task 1.get_Result() at PetaAPI2.Controllers.PetaController.Index() in C:\Users\micha\source\repos\TestAPI\PetaAPI2\Controllers\PetaController.cs:line 24System.Private.CoreLib

Logs from IIS show only error 500 to, nothing else.

How I publish projects into IIS.

  • Created folder on disk for first project and next folder for second project.
  • From iis I add new Web. Select folder, set https and port 5010 for first api project.
  • From iis I add new Web. Select folder, set https and port 5011 for second api project.
  • Select SSL certifacate: IIS Express developer certificate. For both project same.
  • It is all.

Each API is runnig, but error 500 occured when I call api which call api from onather project (web). It works as multiproject run from Visual studio.

Any idea what can by wrong on my IIS site?

https://localhost:5010/test/test - OK, tested from Postman https://localhost:5011/test/testexample - OK, tested from Postman https://localhost:5011/test/callanotherapi - (it must only return data from https://localhost:5010/test/test) show interal server errror 500.

Im sorry about my english. Thank you, Michal

Please check are sslPorts(from launchSettings.json) same.

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