C# Ajax请求后.NET后端的奇怪响应
我试图熟悉ASP.net,所以在“hello world”之后,我尝试添加一些简单的后端请求处理。因此,我正在执行一个从我的页面到asp页面的Ajax请求:C# Ajax请求后.NET后端的奇怪响应,c#,asp.net,.net,ajax,extjs,C#,Asp.net,.net,Ajax,Extjs,我试图熟悉ASP.net,所以在“hello world”之后,我尝试添加一些简单的后端请求处理。因此,我正在执行一个从我的页面到asp页面的Ajax请求: Ext.Ajax.request({ type: 'POST', url: 'http://http://localhost:49852/Default.aspx', params: { html : {'array': document.body
Ext.Ajax.request({
type: 'POST',
url: 'http://http://localhost:49852/Default.aspx',
params: {
html : {'array': document.body.innerHTML}
},
success : function(response){
console.log('RESPONSE !', response);
//me.onSuccess(response, callback, errback);
},
failure : function(response){
console.log('RESPONSE FAIL !', response);
}
});
这是我的页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
现在,如果我在浏览器中访问此地址,我将显示正确(错误)的文本。但是当我尝试使用XHR请求时,我在Firebug控制台中根本看不到任何请求,在Net选项卡中,我得到了“选项”响应:
在登录到控制台时显示如下:
你知道这是怎么回事吗?你的URL错了。它是:
http://http://localhost:49852/Default.aspx
何时应该:
http://localhost:49852/Default.aspx
尝试使用标记为而不是页面
以下是MSDN中的一个示例:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class SimpleWebService : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod]
public string GetServerTime()
{
string serverTime =
String.Format("The current time is {0}.", DateTime.Now);
return serverTime;
}
}
您是否尝试过使用标有
[SciptService]
的Web服务
而不是页面
?是否有链接?这是我使用.net的第一天,因此我深入到示例、演示和文档中:)请参阅以获取一些示例。尝试在请求的方法上设置此属性:[System.Web.Services.WebMethod]这可能只是我的咖啡,但我在您的代码中看到了双精度:)'http://http://
-为了它的价值,Web服务是ajax的发展方向。
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class SimpleWebService : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod]
public string GetServerTime()
{
string serverTime =
String.Format("The current time is {0}.", DateTime.Now);
return serverTime;
}
}