SO BEHEBEN SIE: Der Remote-Server hat einen Fehler zurückgegeben: (400) Bad Request

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: SO BEHEBEN SIE: Der Remote-Server hat einen Fehler zurückgegeben: (400) Bad Request

by Anonymous » 24 Dec 2024, 05:04

Ich versuche, diesen Fehler zu beheben. Ich weiß, dass es weitere ähnliche Fragen mit demselben Fehler gibt, aber die Zeile: request.ContentLength = 0; behebt meine Ausnahme nicht.

Das ist mein Bildcode:

public ActionResult Index()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
string serviceUrl = string.Format(@"http://localhost:61940/Service1.svc/GetPlayer/");

HttpWebRequest request = (HttpWebRequest) WebRequest.Create(serviceUrl);
request.Method = "POST";
request.ContentType = @"application/json; charset=utf-8";
request.ContentLength = 0;

HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Stream stream = request.GetRequestStream();
StreamWriter reader = new StreamWriter(stream);
}


und das ist meine web.config





































Irgendwelche Hilfe? Danke für die Antworten.

und das ist mein Vertrag

[ServiceContract]
public interface IService1
{

[OperationContract]
[WebInvoke(UriTemplate = "GetPlayer", ResponseFormat = WebMessageFormat.Json)]
Player GetPlayer();

[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);

// TODO: Add your service operations here
}

Top