This article transferred from: http://www.cnblogs.com/wucf2004/p/nopcommerce-area.html
What is the area of ASP. NET MVC? Click here to view
If you add an area like admin to the Nopcommerce, the steps are as follows:
1, create a new MVC empty project MvcApplication1, position under \nop.web, add a class MvcApplicationAreaRegistration.cs to register area, the content is as follows:
UsingSYSTEM.WEB.MVC;Namespacemvcapplication1{PublicClassmvcapplicationarearegistration:arearegistration {PublicOverrideStringAreaName {Get{Return"MvcApplication1"; } }PublicOverridevoidRegisterarea (AreaRegistrationContext context) {context. MapRoute ("Mvcapplication1_default"mvcapplication1/{ Controller}/{action}/{id} "new {controller = "home index ", area = " mvcapplication1 " new[] { "mvcapplication1.controllers "}); } }}
2, modify the mvcapplication1/views/_viewstart.cshtml, the content is as follows:
@{ Layout = "~/mvcapplication1/views/shared/_layout.cshtml";}
If you do not change it, you will be prompted not to find the view. 3. Add a homecontroller and corresponding view, which is no longer explained in detail. 4, modify the MvcApplication1 output path, instead: \bin\, otherwise the DLL could not be found. 5, delete the Global.asax file, delete the Web. config does not need the content, you can refer to the config file under Admin. 6, the last key step, modify the method of Nop.web.framework\themes\themeablevirtualpathproviderviewengine.cs GetPath, add the following content:
if (!String. IsNullOrEmpty (areaname) && areaname.equals ("MvcApplication1", stringcomparison.invariantcultureignorecase)) {//Admin area does not support mobile devicesIf(MOBILE) {searchedlocations =Newstring[0];ReturnString. 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 ();
Recompile test, address http://localhost:2619/MvcApplication1/Home.
Sharing is a kind of beauty. Copyright, reproduced Please specify the source http://www.nopchina.net/
[Go] teach you a trick-how to add an area like admin to Nopcommerce