I Have an issue where the following code works when run in Visual Studio however I get a "The resource cannot be found." error when I deploy to the test server.
The JavaScript:
var form = document.forms[0];
form.action = '/NCR/CreateSaveNCR';
form.submit();
The Controller Code:
[HttpPost]
public Acti开发者_C百科onResult CreateSaveNCR(viewModels.NCRCreateViewModel model)
I have no idea what the issue is. Thanks..
if the resource cannot be found, and the code is identical, then it might be a path issue, is the web address http://yourdomain.com/NCR/CreateSaveNCR? or is it in a folder underneath that? You also might (uncommonly) have to restart the IIS process to get it to take in new routing info (rerun global.asax's app_start).
If you deploy to a virtual directory it will need to be included as part of the mvc url path.
Another possibility is that the file exists in the directory in dev but is not included as a project file and is left out of the "publish" deployment method if you push changes to your staging environment using that mechanism.
Never hardcode urls. Always use url helpers when dealing with urls:
form.action = '<%= Url.Action("CreateSaveNCR", "NCR") %>';
精彩评论