[Go] teach you a trick-how to add an area like admin to Nopcommerce

Source: Internet
Author: User
Tags nopcommerce

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.