因爲有時我的系統,不但有GET
型和擊中POST
類型有時。 如果我用[HttpPost]
屬性修飾我的方法,我應該使用JsonRequestBehavior.AllowGet
返回Json結果嗎?我們可以使用帶有[HttpPost]屬性的JsonRequestBehavior.AllowGet嗎?
如:
[HttpPost, ValidateAntiForgeryToken, Authorize]
public ActionResult AssociatedDevices(long id, [DataSourceRequest] DataSourceRequest request)
{
var dataParameters = request.ToDataParameters();
var deviceSetLogic = new DeviceSetLogic();
var associatedDevices = deviceSetLogic.GetAssociatedDevicesByDeviceSetId(id, dataParameters);
var result = new DataSourceResult()
{
Data = associatedDevices,
Total = Convert.ToInt32(dataParameters.TotalRecordCount)
};
return Json(result, JsonRequestBehavior.AllowGet);
}
如果我寫上面一樣在PROD環境會造成任何問題?請指教。
裝飾如果你的方法裝飾有'HttpPost'屬性,你並不需要使用'JsonRequestBehavior.AllowGet'。爲什麼不在運送到PROD之前在本地進行測試? – Shyju
以來,在督促環境中,我們越來越像 「System.Web.HttpException 公共行動方法‘AssociatedDevices AdminSite.Web.Controllers.EntitlementsSearchController’是不是在控制器中發現‘異常的’。」 但我們無法在localhost中重現此錯誤。某處系統正在觸碰GET類型而不是POST,這會導致此錯誤。 –