當我發送Ajax請求我text.aspx
文件,然後我有錯誤405 (Method not allowed)
但是當我加入這個我web.config
然後我有401 (Unauthorized)
ASP.NET AJAX PUT不允許的方法和未經授權的
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/> <!-- ADD THIS -->
</modules>
</system.webServer>
</configuration>
下面我test.aspx.cs文件和Test.aspx的
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Test : System.Web.UI.Page {
public string method;
public int age = 24;
protected void Page_Load(object sender, EventArgs e) {
method = Request.ServerVariables["request_method"];
if(method=="PUT") {
Response.Clear();
Response.Write("PUTEM JE");
Response.End();
}
}
}
Test.aspx的
<%@ Page Language="C#" CodeFile="test.aspx.cs" inherits="Test" %>
<body>
<script>
var xhr = new XMLHttpRequest();
xhr.onload = function(e) {
console.log(e);
}
xhr.open('put', '/moja/test.aspx', true);
xhr.send();
</script>
</body>
</html>
有人能告訴我什麼是錯的?
仍然不工作。 – user3075373