ASP.NET MVC区域空间问题 [英] ASP.NET MVC area namespace problem

查看:110
本文介绍了ASP.NET MVC区域空间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创造我的asp.net MVC 3解决方案,新的区域名为管理即可。 Visual Studio中自动分配的名称空间:

I create a new area in my asp.net mvc 3 solution named admin. Visual studio automatically assign the names space:

MyApp.areas.admin.controllers

我将其更改为 MyApp.admin.controllers

但它停止解析的动作。结果
在这方面的任何帮助将AP preciated。结果
谢谢

But it stops resolving the action.
Any help in this regard will be appreciated.
Thanks

推荐答案

您需要指定注册为您的管理区域的路由时,新的命名空间。

You need to specify the new namespace when registering the route for your admin area.

在您的\\区\\ ADMIN \\ adminAreaRegistration.cs文件,您需要修改RegisterArea()方法如下:

In your \Areas\admin\adminAreaRegistration.cs file, you need to modify the RegisterArea() method as follows:

public override void RegisterArea(AreaRegistrationContext context)
{
    context.MapRoute(
        "admin_default",
        "admin/{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional }, 
        new string[] { "MyApp.admin.Controllers" }  // specify the new namespace
    );
}

这篇关于ASP.NET MVC区域空间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆