我在做什么错?没有命中该操作,错误是405 - >不允许使用HTTP动词POST来访问路径“somepath”。jQuery发布到ASP.NET MVC控制器操作 - 不允许的方法
客户端脚本
$.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
这是我的世界。 ASAX。
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
);
现在的错误 - 资源未找到。该脚本位于模板创建的标准/脚本文件夹中。
那并不是。 t似乎也工作..我更新了这个问题 – Nick 2011-05-16 00:20:04
这是行不通的,因为你刚才在问题中发布的代码改变了整个问题的解决方法。 – 2011-05-16 00:29:06
好吧,你是对的..现在它说我有一个坏请求 – Nick 2011-05-16 00:36:59