开发者

.NET MVC2 - My area url does not register?

开发者 https://www.devze.com 2023-01-25 16:42 出处:网络
I have a new MVC-2 project where I added the area \'member\'. I created a controller named: \'profile\'.

I have a new MVC-2 project where I added the area 'member'. I created a controller named: 'profile'.

This works: http://localhost:1234/Profile (loads up the index() function)

This however doesn't: http://开发者_StackOverflow社区localhost:1234/Member/Profile (i get a 404 error)

Am I missing something here?


There's no reason for this not working. From the default project template:

  1. Right click on the project Add -> Area : Member
  2. In ~/Areas/Member/Controllers add ProfileController containing a default Index action
  3. In ~/Areas/Member/Views/Profile add Index.aspx
  4. Run the application and navigate to /member/profile => it shows the newly added page


Can you check your Global.asax.cs file, see whether it has the following code in Application_Start

AreaRegistration.RegisterAllAreas();


If http://localhost:1234/Profile works, you might need to check the namespace of your ProfileController. It should be:

namespace YourProjectName.Areas.Member
0

精彩评论

暂无评论...
验证码 换一张
取 消