开发者

Matching route in ASP.NET MVC 3 returns a 404

开发者 https://www.devze.com 2023-03-06 16:00 出处:网络
So, all of the sudden when I try to access a newly created controller in my ASP.NET MVC 3 app, it returns a 404 error. I\'ve made sure that the controller is named properly, the route match according

So, all of the sudden when I try to access a newly created controller in my ASP.NET MVC 3 app, it returns a 404 error. I've made sure that the controller is named properly, the route match according to the RouteDebugger, and I've confirmed that a folder for the controller exists in the Views folder and that the properly named View for the action also exists. All of this is in an Area. Oh, and I'm running this on the Visual Studio dev server, not on IIS.

So, I've been at it for about 2 hours and am not getting anywhere, so I'm hoping someone here can point me in the right direction. Here's the source for the controller and routes:

//  AdministrationAreaRegistration.cs
public override void RegisterArea(
    AreaRegistrationContext AreaRegistrationContext) {
    AreaRegistrationContext.MapRoute("8UVhDc", "Administration/{controller}/{DocumentTypeId}", new {
        action = "List"
    }, new {
        controller = @"Documents",
        DocumentTypeId = @"\d+"
    });
}

//  DocumentsController.cs
public sealed class DocumentsController : AdminController {
    [Inject]
    public DocumentsController(
        CookieManager CookieManager,
        DocumentTypeManager DocumentTypeManager)
        : base(CookieManage开发者_如何学JAVAr: CookieManager, DocumentTypeManager: DocumentTypeManager) {
    }

    [HttpGet]
    public ActionResult List(
        short DocumentTypeId) {
        return this.View(new AdministrationView {
            Cookie = base.Cookie,
            DocumentTypes = base.DocumentTypes
        });
    }
}

And ofcourse, there's a folder named "Documents" in the "Views" folder, and in the "Documents" folder there is a view named "List". As far as I can tell, I shouldn't be getting this error (that probably is something a programmer shouldn't say?)...

Anyway, it would be super-duper awesome if someone points out what I'm obviously screwing up. Thanks in advance!


Make sure that the DocumentsController is defined in the XXX.Areas.Administration.Controllers namespace where XXX is the name of your application. Also make sure that the url you are requesting matches the route constraints:

http://localhost:35076/Administration/Documents/123


please see the error 404 here http://support.microsoft.com/kb/315122

0

精彩评论

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