WCF:the underlying connection was closed an unexpected error occurred on a receive

Posted by Manorama under ASP.NET MVC on 9/5/2013 | Points: 10 | Views : 1913 | Status : [Member] | Replies : 0
Here i am using Mvc application with WCF service [Windows Service].

I am added one Interface like this :[OperationContract]
IEnumerable<ITDeclaration> GetITDeclarationDetails(long EmpID);
IEnumerable<ITDeclaration> IHRService.GetITDeclarationDetails(long EmpID)
{

ITDeclaration itdetails = new ITDeclaration();
IEnumerable<ITDeclaration> ITDeclarationDetails = (from ITdeclaraion in dbEntities.GetITDeclarationDetails(EmpID)
select new ITDeclaration
{

EmpID = ITdeclaraion.EmpID,
Particulars1 = ITdeclaraion.Particulars,
MonthlyAmount = ITdeclaraion.MonthlyAmount,
NoofMonths = ITdeclaraion.NoofMonths,
AnnualAmnt = ITdeclaraion.AnnualAmnt,
ID = ITdeclaraion.ID
});
foreach (var item in ITDeclarationDetails)
{

if (item.ID == 1)
{
itdetails.MARentPaidByEmp = item.MARentPaidByEmp;
itdetails.NMRentPaidByEmp = item.NMRentPaidByEmp;
itdetails.AARentPaidByEmp = item.AARentPaidByEmp;
}
if (item.ID == 2)
{
itdetails.MALifeInsPrem = item.MALifeInsPrem;
itdetails.NMLifeInsPrem = item.NMLifeInsPrem;
itdetails.AALifeInsPrem = item.AALifeInsPrem;
}
if (item.ID == 3)
{
itdetails.MAPubProvFund = item.MAPubProvFund;
itdetails.NMPubProvFund = item.NMPubProvFund;
itdetails.AAPubProvFund = item.AAPubProvFund;
}
return ITDeclarationDetails ;
after i implemented

[HttpPost]
public ActionResult Index(ITDeclarationModel ITDeclarationmodel)
{
HRServiceClient client = new HRServiceClient();
//client.GetITDeclarationDetails(ITDeclarationmodel.EmpID);
client.Open();
var ViewITDetails = client.GetITDeclarationDetails(ITDeclarationmodel.EmpID);
if (ViewITDetails.Count() == 0)
{
TempData["ViewEmpID"] = "Please enter valid EmployeeID";
ITDeclarationmodel.EmpID = 0;
client.Close();
return View("Index", ITDeclarationmodel);
}
//ITDeclarationmodel.EmpID = ViewITDetails[0].EmpID;
ITDeclarationmodel.MARentPaidByEmp = ViewITDetails[0].MARentPaidByEmp;
ITDeclarationmodel.NMRentPaidByEmp = ViewITDetails[1].NMRentPaidByEmp;
ITDeclarationmodel.AARentPaidByEmp = ViewITDetails[2].AARentPaidByEmp;
//for Life Insurance Premium
ITDeclarationmodel.MALifeInsPrem = ViewITDetails[0].MALifeInsPrem;
ITDeclarationmodel.NMLifeInsPrem = ViewITDetails[1].NMLifeInsPrem;
ITDeclarationmodel.AALifeInsPrem = ViewITDetails[2].AALifeInsPrem;
}

but i am getting the underlying connection was closed an unexpected error occurred on a receive.

please help me,

Thanks & Regards
Manorama

ManoRama


Responses

(No response found.)

Login to post response