Configure Storebuilder with new Umbraco Web Project
Step 1 - Create new empty Web Project.
Step 2- Add Umbraco Nuget packages.
Step 3 - Create SQL Database and update connection string.
NOTE: Umbraco considers the database unconfigured if their is no valid connection string. If you manually add the new connection string to the web.config within Visual Studio, Umbraco will not correctly run the Umbraco setup wizard when first launched.
NOTE: If you want to force umbraco to re-run the setup wizard, you must delete the connection string and any value from 'umbracoConfigurationStatus' configuration element. See https://our.umbraco.org/wiki/reference/webconfig/
Link to Umbraco Tutorial for setting up content types, etc.
Step 4 - Add StoreBuilder Nuget packages.
StoreBuilder hosts a private nuget server for our components. If this is your first time using StoreBuilder Nuget, please see Configuring Visual Studio to access the StoreBuilder Nuget Server
Add StoreBuilder Nuget Packages:
- StoreBuilder
- StoreBuilder.Log4net
- StoreBuilder.Mvc
- StoreBuilder.UmbracoConnector
- StoreBuilder.Admin
Updating log4net Assembly Bindings
StoreBuilder.Log4net will be using an up-to-date version of Log4net using the latest published log4net package on nuget. As of the date this article was written, Umbraco was 2 minor versions earlier and using an unsigned log4net assembly. You may need to create an umbraco specific assembly binding to make everything work nicely together.
- Create a
\umbraco
folder inside\bin
- Copy the log4net file distributed with Umbraco into this
\bin\umbraco
folder. Currently that is 1.2.11 (while the latest release on nuget is 1.2.13). - Add the following assembly bindings to your
web.config
Sample web.config
assembly binding configuration element:
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="null" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.11.0" newVersion="1.2.11.0" />
<codeBase version="1.2.11.0" href="bin\umbraco\log4net.dll" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" />
<bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="1.2.13.0" />
<codeBase version="1.2.13.0" href="log4net.dll" />
</dependentAssembly>
Updating Newtonsoft.Json Assembly Bindings
Also note that StoreBuilder will always be compiled against the latest version of Newtonsoft.Json again using the latest published Nuget package. Similar to the above you may add an assembly binding to the web.config to upgrade any older references to use the newer assembly.
Sample web.config
assembly binding configuration element:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
Step 5 - Configure StoreBuilder to use Umbraco security provider for authentication
Add StoreBuilder
section to your web project's web.config file.
Part A - Add configSection declaration:
<section name="storebuilder" type="StoreBuilder.Config, StoreBuilder" />
Part B - Add <storebuilder>
configuration element.
<storebuilder>
<database connectionStringName="Storefront" />
<logProvider type="StoreBuilder.Log4Net.LogProvider, StoreBuilder.Log4Net" />
<securityProvider type="StoreBuilder.UmbracoConnector.Security.UmbracoSecurityProvider, StoreBuilder.UmbracoConnector" />
<license accountKey="25RD-V3QU-NA56-PGQY" licenseKey="AAAA-AQA5-CGL2-CZCR-3Y7W-V5ZW-UU2N-73FY-YHUO-TWZO-NRMP-SLXD-FOEU-LN7W-JJLZ-LC4S-BEPY-RXND" />
</storebuilder>
If you remove the logProvider configuration element, you will simply have no logging configured but StoreBuilder will run fine.
Step 6 - Add StoreBuilder namespaces to your Web.config for Razor views
Add the StoreBuilder namespace to the Web.config in your Views folder so that StoreBuilder HtmlHelper extension methods work properly in your Razor views.
<configuration>
<system.web.webPages.razor>
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="StoreBuilder" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>
Step 7 - Add a PageWrapper razor view
The StoreBuilder.Mvc nuget package contains an MVC StoreBuilderController which is used to integrate StoreBuilder functionality into a regular MVC project. While all StoreBuilder core features and plugins use Handlebars for templating, markup intended to be rendered as a page will be passed through this StoreBuilderController and wrapped with a surrounding Razor view in order to make site wide consistency easy for the MVC developer.
In your Views folder, add a new folder called 'StoreBuilder'. Then add a new Razor view in the StoreBuilder folder named 'PageWrapper.cshtml'.
As a minimum this template may appear as follows:
@model StoreBuilder.Content.Results.PageContentResult
@Html.Raw(Model.Body)
@section scripts{
@Html.RenderScripts(Model.ThemeResourceArea)
}
Step 8 - Create a /themes
folder for your StoreBuilder themes
StoreBuilder will be default look for a /themes
folder in the root of your project to discover any StoreBuilder theme files. Each theme should be contained within a subfolder of the root /themes
folder.
The default theme should be aptly named 'default' and contained within the /themes/default
folder.
For more information see StoreBuilder ThemeEngine.
Step 9 - Secure the /storebuilder
project path
If you installed the StoreBuilder.Admin nuget package, it will have added the StoreBuilder folder to your web project which contains an admin portal for StoreBuilder. All the API used by this admin portal will already be secured, however securing the admin portal files will add one more layer of protection to your website and prevent public review of your admin portal code or configuration.
<location path="storebuilder">
<system.web>
<authorization>
<allow roles="StoreBuilder.Admin" />
<deny users="*" />
</authorization>
</system.web>
</location>