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
}
SO BEHEBEN SIE: Der Remote-Server hat einen Fehler zurückgegeben: (400) Bad Request ⇐ C#
-
- Similar Topics
- Replies
- Views
- Last post