C# 内容类型为“的POST请求”;应用程序/x-www-form-urlencoded“;在服务器(QA、UAT…)中不工作,但在本地工作正常
下面是我的发帖请求C# 内容类型为“的POST请求”;应用程序/x-www-form-urlencoded“;在服务器(QA、UAT…)中不工作,但在本地工作正常,c#,asp.net,asp.net-mvc-3,C#,Asp.net,Asp.net Mvc 3,下面是我的发帖请求 request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; request.Method = "POST"; request.ContentLength = data.Length; if (timeoutOverride.HasValue) { timeout = timeoutOverride.Value; }
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.Method = "POST";
request.ContentLength = data.Length;
if (timeoutOverride.HasValue)
{
timeout = timeoutOverride.Value;
}
else
{
timeout = GetTimeoutForUrl(request.RequestUri);
}
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(data);
streamWriter.Flush();
streamWriter.Close();
}
var asyncResult = request.BeginGetResponse(null, null);
string responseData;
try
{
using (asyncResult.AsyncWaitHandle)
{
bool complete = asyncResult.AsyncWaitHandle.WaitOne(timeout);
if (!complete)
{
ThrowTimeoutError(url, timeout);
}
using (var webResponse = request.EndGetResponse(asyncResult))
{
using (var responseStream = webResponse.GetResponseStream())
{
using (var responseStreamReader = new StreamReader(responseStream))
{
responseData = responseStreamReader.ReadToEnd();
}
}
}
}
请帮助我,如何使它在服务器上工作,我认为这是服务器配置问题。或者我的请求出现问题,它在本地工作正常,在服务器上不工作。您需要在服务器中指定MIME类型 需要包括IIS设置、MIME类型
您好,谢谢您的回复。我刚刚添加了MIME类型“application/x-www-form-urlencoded”和扩展类型为“.CS”…但仍然不起作用,你知道还有什么变化吗..请帮我解决一下?