我正在调用一个WebMethod
我在availability.aspx文件中编码的函数,我从javascript函数调用它,它webmethod
在Webservice
本地主机网站上运行完美,但在现场我在浏览器的控制台中收到此错误。
POST http:// * / * **/availability.aspx/addEvent 404(未找到)
有什么区别,为什么不在现场工作?
availability.aspx
带有方法的类定义
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Web.Services;
public partial class driver_login_availability : System.Web.UI.Page
{
[WebMethod]
public static int addEvent(ImproperAvailability improperEvent)
{
availability cevent = new availability();
cevent.driverid = improperEvent.driverid;
cevent.name = improperEvent.name;
cevent.startdate = DateTime.ParseExact(improperEvent.start, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
cevent.enddate = DateTime.ParseExact(improperEvent.end, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
if (CheckAlphaNumeric(cevent.name))
{
int key = EventDAO.addEvent(cevent);
List<int> idList = (List<int>)System.Web.HttpContext.Current.Session["idList"];
if (idList != null)
{
idList.Add(key);
}
return key;//return the primary key of the added cevent object
}
return -1;//return a negative number just to signify nothing has been added
}
}
和javascript:
$(document).ready(function () {
//add dialog
$('#addDialog').dialog({
autoOpen: false,
theme: false,
width: 470,
buttons: {
"Add": function () {
//alert("sent:" + addStartDate.format("dd-MM-yyyy hh:mm:ss tt") + "==" + addStartDate.toLocaleString());
var eventToAdd = {
driverid: $("#ctl00_ContentPlaceHolder1_addProjectID").val(),
name: "Available",
start: addStartDate.format("dd-MM-yyyy hh:mm:ss tt"),
end: addEndDate.format("dd-MM-yyyy hh:mm:ss tt")
};
if (checkForSpecialChars(eventToAdd.name)) {
alert("please enter characters: A to Z, a to z, 0 to 9, spaces. remove any dashes or commas or apostrophes. thanks!");
}
else {
//alert("sending " + eventToAdd.title);
PageMethods.addEvent(eventToAdd, addSuccess, addFailure, "User Context");
$(this).dialog("close");
}
}
}
});