因此,我正在從一個C#應用程序發送數據到ASP Web應用程序的項目中工作;問題是當我想發送數據時出現此錯誤:遠程服務器返回錯誤:(405)方法不允許。這裏是我的C#代碼:遠程服務器返回錯誤:(405)方法不允許。 c#
static void Main(string[] args)
{
using (var wb = new WebClient())
{
var data = new NameValueCollection();
string url = "http://localhost:4241/HtmlPage2.html";
data["Text1"] = "Anas";
data["Text2"] = "Anas";
var response = wb.UploadValues(url, "POST", data);
}
}
,在這裏我的ASP代碼(它只是一個HTML頁面進行測試,該代碼在HtmlPage2.html
實現,當我提交按鈕,它的數據傳遞給HtmlPage2.html
)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form method="Post" action="HtmlPage2.html">
<input id="Text1" type="text" name="Text1" />
<input id="Text2" type="text" name="Text2" />
<input id="Button1" type="submit" value="button" />
</form>
</body>
</html>
注:我的IIS已經啓用了:) 所以,如果有人能幫助我,我會非常感激:)
此線程似乎相關:http://stackoverflow.com/questions/13258014/jquery-post-error-405-method-not-allowed。釋義:檢查IIS中的處理程序映射。對於* .html映射,請檢查請求限制並確保POST位於接受的動詞列表中或者選中了所有動詞選項。 – 2013-03-14 17:17:31