Application doesn't read action result method in MVC3
We are using MVC3 and we are trying to create a method in a Controller named UserSesionManager. This method is called from
@using (Html.BeginForm("GetStatTypesDistribution", "UserSesionManager", FormMethod.Post, new { enctype = "multipart/form-data" }))
In the UserSesionmanager Controller we have:
[HttpPost]
public ActionResult GetStatTypesDistribution(FormCollection form)
However when we call it we get this error:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its n开发者_如何学运维ame changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /UserSesionManager/GetStatTypesDistribution
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Also, whe I add a breakpoint it says that the sourcecode is different form the original version. I follow the instructions of right clicking on location but, the error still exists.
Why is this happening, and how can we fix this?
Thanks a lot!
Make sure that the controller is named UserSesionManagerController
and not only UserSesionManager
:
public class UserSesionManagerController: Controller
{
...
[HttpPost]
public ActionResult GetStatTypesDistribution(FormCollection form)
{
...
}
}
Also make sure that you have a default route in global.asax:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Rebuild your solution. Stop the web server you are using for debugging and check to ensure if you are using the built in web server (Cassini) it's not running in the system tray.
F5 in visual studio to debug. If you still get the error load up the modules window from debug menu then modules. Find your code listed in there an look where it's loaded from.
If it's still an issue delete the apps folder from the temporary asp.net files folder and try debugging again but the modules window should give some info.
精彩评论