MVC 3 Area route not working

前端 未结 8 753
有刺的猬
有刺的猬 2020-12-17 18:54

I created a Area in my MVC 3 application called \'Blog\'.

In global.asax I have the following code.

public static void RegisterRoutes(RouteCollection         


        
8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 19:33

    The registration in your area appears to be wrong. You specify a default for your action but not for the controller. Since you typically have Home as the name of the controller you'd need to specify that.

    Also it could be you don't have your folders setup correctly since you should have physically setup:

    • /Areas/Blog
    • /Areas/Blog/Controllers
    • /Areas/Blog/Views

    ... and once you have fixed your blog area route you'll also need:

    • /Areas/Blog/Views/Home << Put your index view in here

    The error you get seems to pretty clearly indicate this is the issue.

提交回复
热议问题