WebHttp ASP.NET 4.0 - Connection closed med objekter, men virker fint med streng
HejJeg har en lille metode i en web service, der ser sådan her ud:
[code] [WebGet(UriTemplate = "MoviesXML")]
[OperationContract]
public XDocument GetMoviesXML()
{
XDocument doc = XDocument.Load(HttpContext.Current.Server.MapPath("~/Data/Movies.xml"));
return doc;
}[/code]
Når jeg kalder den med min client, så får jeg "The underlying connection was closed: The connection was closed unexpectedly", men hvis jeg laver metoden om til at returnere en streng, så virker det fint?
Klienten ser således ud:
[code]
using (HttpClient client = new HttpClient("http://localhost:9090/WVRServices/"))
{
using(HttpResponseMessage msg = client.Get("MoviesXML"))
{
msg.EnsureStatusIsSuccessful();
litMovies.Text = msg.Content.ReadAsString().ToString();
}
}
[/code]