私は間違っていますか?アクションがヒットせず、エラーは405です - > "somepath"というパスへのアクセスに使用されたHTTP動詞POSTは許可されていません。jQuery ASP.NET MVC Controllerへの投稿アクション - メソッドは使用できません
クライアントスクリプト
$.post('/DecisionPoint/ApplicationState', { fileName: fileName, stateString: e });
ファイル名は 'E'
コントローラーアクション
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SaveApplicationState(string fileName, string stateString)
{
string filePath = GetDpFilePath(fileName);
HtmlDocument htmlDocument = new HtmlDocument();
htmlDocument.Load(filePath);
HtmlNode stateScriptNode =
htmlDocument.DocumentNode.SelectSingleNode("/html/head/script[@id ='applicationState']");
stateScriptNode.InnerHtml = "var applicationStateJSON =" + stateString;
htmlDocument.Save(filePath);
return Json("State Updated");
}
UPDATE
は、これは私の世界であるとして単に '文字列' です。アサックス
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"DecisionPoint", // Route name
"{controller}/{action}/{fileName}/{stateString}", // URL with parameters
new { controller = "DecisionPoint", action = "ApplicationState", fileName = UrlParameter.Optional, stateString = UrlParameter.Optional} // Parameter defaults
);
エラーが発生しました - リソースが見つかりません。スクリプトは、テンプレートが作成する標準/スクリプトフォルダにあります。
。私は質問を更新しました – Nick
あなたが質問に投稿したばかりのコードが質問へのアプローチ全体を変更するので、それはうまくいきません –
あなたは正しいです..今、私は悪いと言いますリクエスト – Nick