1

I have built an API with ASP.NET Core 5, when I publish it from my laptop (localhost), I am getting a good response but when I move the project to Windows Server 2019, I can't get a good response anymore (response is null).

I have tried with Postman to understand the issue, from localhost I can get good response but from the server it's always null (but Postman returns 200 as code response).

What I want is to debug the app from the server, please how can I achieve that?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Sylla
  • 87
  • 8
  • 2
    Have you tried writing logs? You normally need privileges for (remote) debugging that you won't get on a production server. So you should have good logs anyway. – nvoigt Feb 07 '22 at 10:08
  • Seconding logging, but if you've published to Azure you can remote debug via Visual Studio into an App Service. – James Gould Feb 07 '22 at 10:16
  • 1
    "What I want is to debug the app from the server, please how can I achieve that?" - Technically you could try to use Remote Debugging over the public Internet, but there's just far too many complications with that. The next best thing is to install Visual Studio locally onto the server itself and do a local debugging session. Note that when you're in Break mode the entire IIS web-server worker process (`w3wp.exe`) will be unable to handle other incoming requests, so don't do this in an active production environment unless it's a dire emergency. – Dai Feb 07 '22 at 10:34
  • 1
    If you ae not getting a response, than most likely you are failing the TLS which occurs before the HTTPS (secure) request. Any other type of failure usually will send a response back with an error status. Make sure you are using a URL with HTTPS not HTTP. What type of machine is your client. Older clients may need updating to work with latest TLS on server. – jdweng Feb 07 '22 at 10:38
  • Hi @nvoigt, i do have logs file and i can see this warning error >> 2022-02-07 09:29:39.5659|WARN|Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware|Failed to determine the https port for redirect. – Sylla Feb 07 '22 at 10:57
  • Hello @jdweng, i am using http request, if i try with https from IIS publish site its not working, but https works from visual studio. do i need to configure a secure https. i am getting this warining error from logs >> 2022-02-07 09:29:39.5659|WARN|Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware|Failed to determine the https port for redirect. – Sylla Feb 07 '22 at 11:01
  • Probably IIS needs upgrading or you have to change client to HTTP. See : https://support.mailessentials.gfi.com/hc/en-us/articles/360015120800-Enabling-TLS-Configuration-on-IIS-SMTP-Server-?force_isolation=true – jdweng Feb 07 '22 at 12:00
  • If my reply is helpful, please accept it as answer(click on the mark option beside the reply to toggle it from greyed out to fill in.), see https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Jason Pan Feb 09 '22 at 02:48

1 Answers1

2

You can't debug your web app with release mode.

From your description, I think you should double check the connection string in your appsetting.json or web.config file.


Suggestion

  1. How to deploy webapp to remote IIS.

  2. Deploy your webapp with debug mode.

    enter image description here

  3. Remote debug your web app.

Jason Pan
  • 15,263
  • 1
  • 14
  • 29
  • Hello @Jason how are you, i have Attached the API Application from visual studio(my laptop ) to the server, but the process is not hitting the break points , or i have to publish it on debug mode??? – Sylla Feb 09 '22 at 12:54
  • @Sylla yes, you can debug it only with debug mode – Jason Pan Feb 09 '22 at 12:56
  • yes @Jason, I have publish it as debug mode but can't hit break points. – Sylla Feb 09 '22 at 13:38
  • @Sylla Can you use screentogif tool to record your debug steps in visual studio? – Jason Pan Feb 09 '22 at 13:40
  • hi @Jason, i have another question please, if i attached the w3wp.exe of my app from the server to visual studio form my laptop, how can i see the output of the app from the server because the code im seing here is my local app codes??? – Sylla Feb 09 '22 at 13:43
  • @Sylla if you can remote debug your webapp, and keep the version of your project is same, and attach the remote w3wp.exe, then you can check the output in your visual studio. – Jason Pan Feb 09 '22 at 13:47
  • Hi @Jason after following step by step the procedure, i am able to debug the app from the server with VS from my laptop and i have see the error: ora-01843 not a valid month. Thanks you so much and also thanks to others. – Sylla Feb 10 '22 at 09:49
  • @Sylla If my reply is helpful, please accept it as answer(click on the mark option beside the reply to toggle it from greyed out to fill in.), see https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Jason Pan Feb 10 '22 at 09:50