Server responded with a status of 500 (Internal Server Error) – MVC C#

I’m getting the Internal Server Error when I tried to get the details by sending ajax request from the Jquery Datatable to the Controller. Even in the controller the code works fine and the result too. But I’m getting this error in both “HTTPGET” and “HTTPPOST” request.

This is my code.

`
Employee.cshtml

Dependencies

    <script src="~/Scripts/jquery-3.4.1.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/DataTables/DataTables-1.13.4/js/jquery.dataTables.js" defer="defer"></script>
<script src="~/Scripts/DataTables/DataTables-1.13.4/js/dataTables.bootstrap.js" defer="defer"></script>

    <script type="text/javascript">
    $(document).ready(function () {
        debugger;
        $('#empTable').DataTable({
            "columnDefs": [
                { "searchable": true,  targets: "_all" },
                { "className": "text-center custom-middle-align", targets: "_all" }
            ],
            "processing": true,
            "serverSide": true,
            "ajax":
            {
                "url": "/Employee/GetEmployeeDetails",
                "type": "POST",
                "dataType": "json",
                "dataSrc": function (response) {
                    debugger;
                    resultObj = $.parseJSON(response.data)
                    return resultObj.data;
                },
                "error": function (jqXhr, textStatus, errorMessage) { // error callback 
                    console.log('Error: ' + errorMessage + '    request.statusText:' + jqXhr.statusText);
                }
            }
        });

    });
</script>

Employee.cs

[HttpPost]
    public JsonResult GetEmployeeDetails()
    {
        connection();
        SqlCommand cmd = new SqlCommand("GetEmployeeDetails", con);
        cmd.CommandType = CommandType.StoredProcedure;
        con.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        DataTable dt = new DataTable();
        dt.Load(dr);

        //Note I have tried both SqlDataAdapter and SqlDataReader
        //SqlDataAdapter da = new SqlDataAdapter();
        //da.Fill(dt);

        con.Close();
        return Json(dt);
    }