如果在ASP.NET MVC 3/4 Razor应用程序中遇到“找不到公共操作方法”的错误,可以尝试以下解决方法:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
RegisterRoutes
方法中包含适当的路由配置。public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// 注册路由
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
@Html.ActionLink("Go to Home", "Index", "Home")
RouteDebugger
来调试路由配置。public static void RegisterRoutes(RouteCollection routes)
{
// 其他路由配置...
// 在调试模式下启用路由调试器
if (System.Diagnostics.Debugger.IsAttached)
{
routes.Add(new RouteDebugger.Routes.DebugRoute("*Debug*", new MvcRouteHandler()));
}
}
希望这些解决方法能够帮助您解决“找不到公共操作方法”的问题。