惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyberwarzone
Cyberwarzone
V
Vulnerabilities – Threatpost
T
Tenable Blog
Forbes - Security
Forbes - Security
Simon Willison's Weblog
Simon Willison's Weblog
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
Project Zero
Project Zero
C
CXSECURITY Database RSS Feed - CXSecurity.com
V
Visual Studio Blog
WordPress大学
WordPress大学
Latest news
Latest news
K
Kaspersky official blog
T
Tailwind CSS Blog
T
Threat Research - Cisco Blogs
B
Blog RSS Feed
C
Cisco Blogs
博客园 - 聂微东
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
小众软件
小众软件
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CERT Recently Published Vulnerability Notes
Cisco Talos Blog
Cisco Talos Blog
S
SegmentFault 最新的问题
Security Latest
Security Latest
Y
Y Combinator Blog
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
L
LINUX DO - 最新话题
月光博客
月光博客
The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
S
Security Affairs
P
Proofpoint News Feed
D
DataBreaches.Net
有赞技术团队
有赞技术团队
云风的 BLOG
云风的 BLOG

博客园 - wucf2004

教你一招 - Misc类型插件的妙用(附带插件源码) 如何在nopcommerce3.3注册页面添加密码强度检查仪? nopcommerce之权限模块 nopcommerce3.3简洁版 nopcommerce里面的@Html.Widget("home_page_top") 是什么? 教你一招 - 如何给nopcommerce做一套自己的主题 nopcommerce之移动版简介 网银在线插件 For Nopcommerce V2.6 支付宝插件 For Nopcommerce V2.6 教你一招 - 如何给nopcommerce增加新闻类别模块 教你一招 - 如何使用中文包 教你一招 - 如何使用nopcommerce主题(v2.5) 教你一招 - 如何安装nopcommerce2.5 PropertyInfo 又一个不错的sql分页存储过程,支持排序、搜索 PageLoad 事件执行两次 js点击显示全部内容(用于内容比较长时) - wucf2004 - 博客园 asp.net解决中文乱码问题 - wucf2004 - 博客园 asp.net根据生日计算年龄(具体到年月天)
教你一招 - 如何给nopcommerce增加一个类似admin的area
wucf2004 · 2014-06-08 · via 博客园 - wucf2004

Posted on 2014-06-08 21:24  wucf2004  阅读(843)  评论()    收藏  举报

asp.net mvc里面的area是什么,点击这里查看

 如果在nopcommerce里面加入类似admin的area,步骤如下:

1、新建一个mvc空项目MvcApplication1,位置放在\Nop.Web下面,添加一个类MvcApplicationAreaRegistration.cs用于注册area,内容如下:

using System.Web.Mvc;
 
namespace MvcApplication1
{
    public class MvcApplicationAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "MvcApplication1";
            }
        }
 
        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "MvcApplication1_default",
                "MvcApplication1/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", area = "MvcApplication1", id = "" },
                new[] { "MvcApplication1.Controllers" }
            );
        }
    }
}

2、修改MvcApplication1/Views/_ViewStart.cshtml,内容如下:

@{
    Layout = "~/MvcApplication1/Views/Shared/_Layout.cshtml";
}

如果不修改的话会提示找不到view的。
3、添加一个HomeController和对应的视图,这里不再详细说明。
4、修改MvcApplication1输出路径,改为:..\bin\,要不然是找不到dll的。
5、删除Global.asax文件,删除web.config里面不需要的内容,可参考admin下面的config文件。
6、最后关键一步,修改Nop.Web.Framework\Themes\ThemeableVirtualPathProviderViewEngine.cs的方法GetPath,添加如下内容:

if (!string.IsNullOrEmpty(areaName) && areaName.Equals("mvcApplication1", StringComparison.InvariantCultureIgnoreCase))
            {
                //admin area does not support mobile devices
                if (mobile)
                {
                    searchedLocations = new string[0];
                    return string.Empty;
                }
                var newLocations = areaLocations.ToList();
                newLocations.Insert(0, "~/MvcApplication1//Views/{1}/{0}.cshtml");
                newLocations.Insert(0, "~/MvcApplication1//Views/{1}/{0}.vbhtml");
                newLocations.Insert(0, "~/MvcApplication1//Views/Shared/{0}.cshtml");
                newLocations.Insert(0, "~/MvcApplication1//Views/Shared/{0}.vbhtml");
                areaLocations = newLocations.ToArray();
            }

重新编译测试一下吧,地址http://localhost:2619/MvcApplication1/Home。

分享是一种美。版权所有,转载请注明出处 http://www.nopchina.net/