What am I doing wrong? The does not hit the action and the error is a 405 - >The HTTP verb POST used to access path "somepath" is not allowed.
Client Script
$.post('/DecisionPoint/ApplicationState', { fileName: fileName, stateString: e });
filename is just a 'string' as is 'e'
Controller Action
[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
This is my global.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
);
The error is now - Resource not found. The script lives in the standard /Scripts folder that the template creates.