[HttpRequestException]:响应状态代码未指示成功:500(内部服务器错误)

时间:2017-07-31 05:32:05

标签: asp.net-mvc asp.net-mvc-4 asp.net-mvc-3 asp.net-web-api

实际上当我尝试从我的localhost运行我的应用程序时,它工作正常。在我将我的应用程序发布到服务器后,它在Firefox中运行良好。但是,当我尝试使用Chrome时,它无效。

错误消息:

[HttpRequestException]: Response status code does not indicate success: 500 
(Internal Server Error).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at SystemMVC_Version2._0.Controllers.ClaimsController.ClaimRecord(String Bill_no, 
   String Bill_date, String VisitDate, String ActualAmount, Double CoPay, Double ClaimAmount, 
   String Cv_Id, String TotalClaimAmount, String Consult_Type, String MemberIDNo, 
   String MCType, String StartDate, String EndDate, String McRemark, String Diagnosis, 
   String DoctorNames, String Medication, String MedicationQty, String MedicationUnitPrice, 
   String MedicationCost, String AdditionalMedicineCode, String AdditionalMedicineQty, 
   String AdditionalMedicationUnitPrice, String AdditionalMedicationCost, String ProcID, 
   String ProcedureCost, String PreferedMedicationSelected, String DocID, String LockAmount, 
   String IsMC, String IsClaim, String IsDepartment, String IsEmployee, String IsDependent, 
   String PatientName, String IsCorp, String Department, String EmailNotDepartment, 
   String MembrType)
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)

我的Ajax电话

 $.ajax({
        beforeSend: function () {
            $("#submit-button").prop('disabled', true); // disable button
        },
        url: '@Url.Action("ClaimRecord", "Claims")',
        data: JSON.stringify({
                                Bill_no: b_no, Bill_date: b_date, VisitDate: pv_date, ActualAmount: ActAmt, CoPay: CpayAmt, ClaimAmount: ClaimAmt,
                                Cv_Id: cv_id, TotalClaimAmount: TotalClaimAmnt, Consult_Type: Type, MemberIDNo: MemId, MCType: resType,
                                StartDate: datefrom, EndDate: dateend, McRemark: remark, Diagnosis: selectedValues, DoctorNames: Doctor,
                                Medication: Medcode, MedicationQty: MedQty, MedicationUnitPrice: MedUnitPrice, MedicationCost: Cost,
                                AdditionalMedicineCode: MedcodeExtra, AdditionalMedicineQty: MedQtyExtra, AdditionalMedicationUnitPrice: MedUnitPriceExtra,
                                AdditionalMedicationCost: CostExtra, ProcID: Procedureid, ProcedureCost: ProcCost, PreferedMedicationSelected: preferdMed,
                                DocID: drid, LockAmount: Lckamt, IsMC: mc, IsClaim: clm, IsDepartment: isdept, IsEmployee: isemp, IsDependent: isdepen,
                                PatientName: pname, IsCorp: iscorp,Department: dept, EmailNotDepartment: endept, MembrType: mtype
        }),

        type: 'post',
        cache: false,
        dataType: 'json',
        async: false,
        contentType: 'application/json;charset=utf-8',

        success: function (response) {
            window.location.href = response.redirectTo;
            alert("This Claim submitted Successfully. Claim ReferenceNo is :" + ' ' + response.par);
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("Not Successfull" + jqXHR.responseText);
            console.log(jqXHR.responseText);
        }
    });

控制器:

  public ActionResult ClaimRecord(string Bill_no, string Bill_date, string VisitDate, string ActualAmount, string CoPay, string ClaimAmount,
                                    string Cv_Id, string TotalClaimAmount, string Consult_Type,  string MemberIDNo, string MCType,
                                    string StartDate, string EndDate, string McRemark, string Diagnosis, string DoctorNames,string Medication,
                                    string MedicationQty, string MedicationUnitPrice, string MedicationCost, string AdditionalMedicineCode,
                                    string AdditionalMedicineQty, string AdditionalMedicationUnitPrice, string AdditionalMedicationCost,
                                    string ProcID, string ProcedureCost, string PreferedMedicationSelected, string DocID, string LockAmount,
                                    string IsMC, string IsClaim, string IsDepartment, string IsEmployee, string IsDependent, string PatientName, string IsCorp,
                                    string Department, string EmailNotDepartment, string MembrType)
    {
            CreateDate = DateTime.Now.ToString();
            string url = "http://ipaddress/SystemAPI/";
            System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
            client.BaseAddress = new Uri(url);
            client.DefaultRequestHeaders.Accept.Clear();
            ClaimTxn ct = new ClaimTxn()
                {
                    CreateUserID = UserId,
                    CreateDate = CreateDate,
                    ModifyUserID = UserId,
                    ModifyDate = CreateDate,
                    ClaimDate = CreateDate,
                    ClaimSubmitDate = CreateDate,
                    BillNo = Bill_no,
                    BillDate = Bill_date,
                    TreatmentStartDate = VisitDate,
                    TreatmentEndDate = VisitDate,
                    MemberID = MemberIDNo,
                    ProviderID = PID,
                    ProviderName = ProviderName,
                    Amount = ActualAmount,
                    Copay = CoPay,
                    McType = MCType,
                    McStartDate = StartDate,
                    McDays = Days,
                    ClaimAmount = TotalClaimAmount,
                    ConfirmVisitID = Cv_Id,
                    ConsultationType = Consult_Types
                };

            HttpResponseMessage response = client.PostAsJsonAsync<ClaimTxn>("api/ClaimSubmisstion/InsertintoClaimTxn", ct).Result;
            System.Diagnostics.Debug.WriteLine(response);
  }

所以,当我从localhost运行应用程序时,没有问题。响应代码是201.但是当我尝试使用chrome从服务器运行时,我得到状态代码500.那么我该如何解决这个问题。 任何帮助appriciated。在此先感谢!!!

0 个答案:

没有答案