0
当我尝试访问agency
区域中的家庭控制器中的索引方法时,我收到IIS 404错误消息。如果我更新route
属性为:[Route("{action}")]
它工作正常,但我想保留index
作为默认路由。404区域中的属性路由
在我看来,我有这样的:
@Html.ActionLink("Click here", "index", "home", new { area = "agency" }, new { @class = "btn btn-block btn-lg btn-primary" })
的HomeController原子能机构地区
namespace ProjectName.UI.Areas.Agency.Controllers
{
[RouteArea("agency")]
[RoutePrefix("home")]
[Route("{action=index}")]
public class HomeController : BaseController
{
public ActionResult Index()
{
return View();
}
}
}
RouteConfig:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
AreaRegistration.RegisterAllAreas();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "home", action = "index", id = UrlParameter.Optional },
namespaces: new[] { "ProjectName.UI.Controllers" }
);
}
我也有一个管理区,看起来完全一样除RouteArea
之外的机构区域是admin
,我没有任何问题。
任何建议都会受到欢迎。