常见故障及解决方法
1、Visual Studio可以运行程序但是没法调试断点
解决方法: 把运行旁边的Release 改成 Debug
2.路由规则对地址的影响
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "ShopManage", url: "ShopManage/{controller}/{action}/{id}", defaults: new { controller = "Products", action = "AddProduct", id = UrlParameter.Optional }, namespaces: new string[] { "MvcWeb.Controllers.ShopManage" } ); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
如果用:
return RedirectToAction("FindPwd", "ForgotPwd");
浏览器地址就会被解析成 http://localhost:8050/ShopManage/ForgotPwd/FindPwd 多了一个“ShopManage”
这种情况下我们最好用 return Redirect("/ForgotPwd/FindPwd"); 这样会解析成正确的地址 http://localhost:8050/ForgotPwd/FindPwd