Dnn 7是否支持MVC模块开发?求相关开发文档链接
Dnn 7 MVC Module Development Support: What You Need to Know
Hey there! Let's clear this up right away: Dnn 7 does support MVC module development, but only starting with version 7.2. Earlier releases (7.0 and 7.1) don't include any MVC integration at all, which is probably why you struggled to find docs focused on Dnn 7 specifically.
Key Details to Keep in Mind
- Framework Lock: Dnn 7.2's MVC support is tied directly to ASP.NET MVC 3—you can't use newer MVC versions (like 4 or higher) here, so make sure your project targets that framework.
- Module Structure Differences: Unlike Dnn 8+, the MVC module structure in 7.2 is more constrained:
- Controllers must inherit from
DotNetNuke.Web.Mvc.Framework.Controllers.DnnController(not the laterDnnMvcControlleryou might see in 8+ docs) - Views follow standard ASP.NET MVC conventions, but need to live in a
Views/{ControllerName}folder within your module - Your
.dnnmanifest file requires a specificMvcModulecomponent to register controllers, like this:<components> <component type="MvcModule"> <controllers> <controller name="Home" type="YourModule.Controllers.HomeController, YourModule" /> </controllers> </component> </components>
- Controllers must inherit from
- Routing: Dnn handles routing automatically for MVC modules in 7.2—you don't need to manually register routes. Access your module's actions via paths like
/DesktopModules/YourModuleName/Home/Index
Quick Development Walkthrough
- Set up a class library project targeting .NET Framework 4 (since Dnn 7.2 runs on this), then add references to
DotNetNuke.dll,DotNetNuke.Web.Mvc.dll, andSystem.Web.Mvc.dll(version 3.0.0.0) - Create a controller that inherits from
DnnControllerand add your action methods (e.g.,Index()) - Add corresponding views in the correct
Viewssubfolder structure - Configure your
.dnnmanifest with theMvcModulecomponent to register your controller - Compile, package your module (DLL + views + manifest), and install it on a Dnn 7.2+ site
Important Caveats
- Dnn 7.2's MVC support is fairly basic compared to later versions—features like areas, advanced route customization, or integrated dependency injection aren't available here
- Double-check your Dnn site's exact version: if it's pre-7.2, MVC modules won't work at all
内容的提问来源于stack exchange,提问作者Jacques
相关产品推荐
相关产品推荐

