Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Start by installing an Episerver CMS website using the standard installer. The default options produce a website in c:\EPiServer\Sites\[MySiteName]. In the following example, the site was installed in c:\EPiServer\Sites\ExampleEPiServerSite4.
Note: While not required for normal operation, this tutorial assumes you have installed ASP.NET MVC.
You should make the following modifications to the default MVC application.
Remove the default controllers, views and scripts (HomeController.cs, /Views/Home, and so on) according to the following image. You always can use another project to play with ASP.NET MVC. If you have added a unit test project, you also have to remove the related test functions from the QuickChat.Test project.
The web configuration is inherited from the public templates site, but if you leave some settings in the module’s web.config, you will keep intellisense enabled.
Copy the root web.config file from the QuickChat example zip (not the one in the Views folder) to your project.
Open the QuickChat project’s properties and change the default build output path of the quick chat project to ..\..\bin\.
Open the public templates’ web.config file and find the episerver.shell configuration section. Add the QuickChat module to the /configuration/episerver.shell/modules/ path. This is an excerpt of the added configuration:
<episerver.shell>
<publicModules rootPath="~/modules/" autoDiscovery="Minimal">
<!-- QuickChat is assumed to be located in ~/modules/QuickChat -->
<add name="QuickChat">
<assemblies>
<add assembly="QuickChat"/>
</assemblies>
</add>
</publicModules>
While you create gadgets in a separate project, you can create gadgets in the PublicTemplates.csproj project by modifying the configuration and the csproj file.
<episerver.shell>
<publicModules rootPath="~/modules/" autoDiscovery="Minimal">
<add name="Public" resourcePath="~/">
<assemblies>
<add assembly="EPiServer.Templates.Public" />
</assemblies>
</add>
The ASP.NET MVC framework suggests that you organize the code in the following folders; add these to your project:
<Project>
<PropertyGroup>
<ProjectTypeGuids>{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
</ProjectTypeGuids>
using System.Web.Mvc;
using EPiServer.Shell.Gadgets;
namespace QuickChat.Controllers
{
[Gadget]
public class QuickChatController : Controller
{
public ActionResult Index()
{
return
Content("<strong>Some</strong>thing!");
}
}
}
The dashboard contains "something" that you can continue to work with.
Dashboard gadgets are developed using the MVC model. The following example shows the model from the perspective of processing a server request.
Incoming Request > Dashboard Controller Action > Dashboard View > Outgoing Response
The Controller Action and View represent code that is developed to provide functionality. The arrows (>) represent pluggable points provided by the ASP.NET MVC framework.
In a typical ASP.NET MVC application, the flow spans over a complete page request. However, in the case of dashboard gadgets, this is slightly different:
Incoming Request Dashboard Controller Action Dashboard View
foreach (gadget on userDashboard)
{
Partial Request Controller Action View
} Outgoing Response
Dashboard gadgets use the same principles as a typical MVC application but only renders a portion of the dashboard.
Last updated: Nov 25, 2015