1

I am using mvc4 as my web application which inherits a WCF service i have an Entity framework and used Code first for database Now, Entity layer is inherited to both MVC as well as to WCF but Data Access layer is only inherited to the WCF, Now when ever i call the WCF method from my controller the method is called nicely and the method works fine into the WCF and returns the expected result but when it returns result to the MVC application it throws an exception of "The underlying connection was closed: An unexpected error occurred on a receive." can anyone please help me out, following is the code respectively:-

for Controller class

  public ActionResult CustomerSearch()
    {

        APIServiceDaman.Customer ObjTestEn = new APIServiceDaman.Customer();
        using (Objjj = new APIServiceDaman.Service1())
        {

          var  ObjTestEn2 = Objjj.GetUserDetails(1, true);
        }


        return View(ObjTestEn);
    }

for WCF:-

 public X.Entities.Customer GetUserDetails(int CustomerID)
    {
        X.Entities.Customer objtest = new X.Entities.Customer();
        using (ObjCustomerEvidence = new CustomerManager()) 
        {
            objtest = ObjCustomerEvidence.GetCustomerByID(CustomerID);
        }
        return objtest;


    }

for DataAccess Layer:-

 public Entities.Customer GetCustomerByID(int ID)
    {
        return DBContext.Customer.Where(c => c.ID == ID).FirstOrDefault();
    }
nik_boyz
  • 165
  • 3
  • 15
  • when i saw this, it was due to either the pocos not being marked as data contracts, or they had a circular reference in them. you could try turning on wcf tracing http://stackoverflow.com/questions/4271517/how-to-turn-on-wcf-tracing and look for the exception that is thrown – Slicksim Jul 25 '13 at 07:58
  • Still i am not able to resolve this problem and nobody is even helping here :( – nik_boyz Jul 29 '13 at 09:24
  • Where did the tracing say the exception occurred? – Slicksim Jul 30 '13 at 09:38

1 Answers1

0

First of all check your web.config setting for executionTimeout and maxRequestLength on both side WCF and your MVC4 client. for more information on this please refer this below link there is a good answer given by jlchereau, follow this steps and try to check it out again, it might help you out. also try to enable WCF tracing (Tracing) and find out the root of exception it will help you a lot to resolve your issue.

http://velodocaddin.codeplex.com/discussions/40792

Tejas Vaishnav
  • 466
  • 5
  • 20