標籤:blank space 點擊 override frame conf oca cti ext
本文轉自:http://www.cnblogs.com/wucf2004/p/nopcommerce-area.html
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/
[轉]教你一招 - 如何給nopcommerce增加一個類似admin的area