我有一个WebMethod,在本地运行得很好。
我已经更新了免费托管服务提供商的代码,以及一些方法不再适用的方式我总是得到。
Unknown web method saveformdata/.
要查看该页面,请Click here。我尝试了多个步骤,但每次它在本地工作正常但不在线。
METHOD : Default.aspx.cs
[System.Web.Services.WebMethod(EnableSession = true)]
[System.Web.Script.Services.ScriptMethod()]
public static string saveformdata(string html)
{
string messagetxt = string.Empty;
try
{
html = "<html><body><div id=\"formText\" style=\"margin:0 auto; width:700px; font-family:Gotham, 'Helvetica Neue', Helvetica, Arial, sans-serif; color:#3f3f3f; font-size:12px; \">" + html + "</div></body></html>";
long milliseconds = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) / 1000;
Random rnd = new Random();
int x = rnd.Next(1000, 9999);
int y = rnd.Next(1000, 9999);
int z = rnd.Next(1000, 9999);
milliseconds = milliseconds + x + y + z;
string path = HttpContext.Current.Request.MapPath("~/Questionaires");
File.WriteAllText(path + "\\" + milliseconds + "_form.html", html);
messagetxt = "Form Saved Successfully. Thank you for your time.";
return messagetxt;
}
catch (Exception ex)
{
messagetxt = ex.ToString();
}
return messagetxt;
}
METHOD : Default.aspx
function saveForm()
{
var bodytag = document.getElementById("formText");
var html = bodytag.innerHTML;
var dataToSend = JSON.stringify({ 'html': html });
//PageMethods.saveform(html, Success,callerMethod_Failure);
$.ajax({
type: "POST",
url: "Default.aspx/saveformdata",
data: dataToSend,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccessAjax,
failure: function(response) {
alert(response.d);
}
});
}
function OnSuccessAjax(response) {
alert(response.d);
}
我在这里做错了什么?
谢谢