2017-06-22 24 views
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" } 
    ); 
} 

私も全く同じに見えます管理エリアを持っている私の見解では

私はこれ持っています代理店エリア:RouteAreaadminで、私は持っていません問題がある。

いずれの提案も歓迎されます。

答えて

0

この問題は、私のエリアがAgencyと呼ばれ、私のViewsフォルダにAgencyと呼ばれる別のサブフォルダがあるためです。 agency/home/indexにルーティングする代わりに、agencyフォルダ内でhomeビューを検索しようとしていました。

関連する問題