我们正在使用MVC3,并试图在一个名为UserSesionManager的控制器中创建一个方法。此方法是从
@using (Html.BeginForm("GetStatTypesDistribution", "UserSesionManager", FormMethod.Post, new { enctype = "multipart/form-data" }))在UserSesionmanager控制器中,我们有:
[HttpPost]
public ActionResult GetStatTypesDistribution(FormCollection form)然而,当我们调用它时,我们得到这个错误:
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 name 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另外,当我添加一个断点时,它会显示源码与原始版本不同。我按照右击location的指示操作,但错误仍然存在。
为什么会发生这种情况,我们如何解决这个问题?
非常感谢!
发布于 2011-10-08 22:26:07
确保控制器的名称为UserSesionManagerController,而不仅仅是UserSesionManager
public class UserSesionManagerController: Controller
{
...
[HttpPost]
public ActionResult GetStatTypesDistribution(FormCollection form)
{
...
}
}另外,请确保您在global.asax中有默认路由:
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);发布于 2011-10-08 23:06:07
重新构建您的解决方案。停止用于调试的web服务器,并检查以确保您使用的是内置web服务器(Cassini),它没有在系统托盘中运行。
要调试的F5。如果你仍然得到错误加载模块窗口从调试菜单,然后模块。找到在那里列出的代码,看看它是从哪里加载的。
如果仍然有问题,请从temporary asp.net文件夹中删除应用程序文件夹,然后再次尝试调试,但是模块窗口应该会给出一些信息。
https://stackoverflow.com/questions/7697420
复制相似问题