Catching SqlException does not work in my rest API
EDIT: Just delete this question. I currently don't have time to follow up
I'm having an issue, when my rest API code is deployed on our test server. I have the below code. This works fine on my development machine, but when deploying to our test-server and calling this method, all I'm getting is 500 internal error and the log file is not created. If I remove the part where it catches the SqlException, then calling the method works as expected and my log file is correctly created
I have installed the Nuget package System.Data.SqlClient 4.8.5
Does anybody have any idea what I am missing? From what I can tell, the System.Data.SqlClient.dll file on the server is the same as on my development machine
[HttpPut("Proposal/{labelId}/{buildId}/{identId}/{proposalId}")]
public ResponseOpaqueConstruction AddProposal(int labelId, int buildId, int identId, int proposalId)
{
ResponseOpaqueConstruction response = new ResponseOpaqueConstruction();
try
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Temp\TellMeSomething.log", true))
file.WriteLine(DateTime.Now.ToString("T") + " - Inside try");
}
catch (SqlException ex)
{
}
catch (Exception ex)
{
}
return response;
}