This guide is my ultimate guide to setting up Sitefinity. I’ll be updating it as I find new things that I commonly do when I want to setup a new project. Today, I’ll be going over common Visual Studio solution changes, Sitefinity Settings and more that I use on almost every project.
In Part One, I setup the base solution and continuous integration with Visual Studio Team Services. This post will be more about actual settings in the Sitefinity project.
Storage Mode of Configurations
What is it?
Sitefinity has 4 separate configuration storage mechanisms that are explained pretty well in the documentation link. The default mode is Auto Storage which means that environment based settings in the file system and application based settings are hosted in the database. This mode is perfect for CI deployments as it allows application settings changes in multi-server environments and the environment settings should be settings that are rarely changed anyways.
On top of this, its possible to set remote servers configurations to Read-Only. This is great because it prevents some users from accidentally making configuration settings that would cause your site to recycle. It also prevents the server having changes that are not stored in source control.
To set all of this, you should add a web.config transform by right clicking on the web.config file and clicking the ‘Add Config Transform’. Then find the transformation file you want to use and add the following code.
<telerik> <sitefinity> <sitefinityConfig storageMode="Auto" restrictionLevel="ReadOnlyConfigFile" xdt:Transform="Replace"/> </sitefinity> </telerik>
Sitefinity by default stores its connection string in the DataConfig.config file found in the App_Data folder. This makes multiple environment setups more difficult to maintain and prevents the ability to encrypt the connection string especially if there is a password field. To accomplish this, do NOT delete the DataConfig.config but just remove the connection string line and add it to the web.config.
<?xml version="1.0" encoding="utf-8"?> <dataConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="10.1.6502.0" initialized="True"> <connectionStrings> </connectionStrings> </dataConfig>
<connectionStrings> <add name="Sitefinity" connectionString="data source=XXXXXXXXXX;Integrated Security=True;;initial catalog=PublicWebsite" providerName="System.Data.SqlClient" /> </connectionStrings>
<connectionStrings> <add name="local" connectionString="data source=XXXXXXXX;Integrated Security=True;;initial catalog=PublicWebsite" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings>
Login HTTPS Security
It’s super important to setup HTTPS security for the login and Sitefinity is not setup like this by default. The great news is that it takes very little to do. Documentation
<system.identityModel.services> <federationConfiguration> <wsFederation passiveRedirectEnabled="true" issuer="http://localhost" realm="https://localhost" requireHttps="true" /> <cookieHandler requireSsl="false" /> </federationConfiguration> </system.identityModel.services>
<securityTokenIssuers> <add key="" membershipProvider="Default" realm="http://localhost" /> <add key="" membershipProvider="Default" realm="https://localhost" /> <add key="" membershipProvider="Default" realm="https://www.example.com" /> <add key="" membershipProvider="Default" realm="https://example.com" /> </securityTokenIssuers> <relyingParties> <add key="" realm="http://localhost" /> <add key="" realm="https://localhost" /> <add key="" realm="https://www.example.com" /> <add key="" realm="https://example.com" /> </relyingParties>
While you’re in the SecurityConfig.config you should add your SMTP information for password recovery. Here’s what it would look like
<membershipProviders> <add enablePasswordRetrieval="true" recoveryMailAddress="email@example.com" name="Default" config:flags="1" /> </membershipProviders>
<smtpSettings host="example.outlook.com" port="587" userName="firstname.lastname@example.org" password="XXXXX" />
Sitefinity does a great job with the instructions for setting up ELMAH on their sites. I’m just collecting everything here. Documentation
- Install ELMAH on SQL Server first
- Run added SQL script on Sitefinity database to create ELMAH stored procedures and tables.
<uiElmahSettings isElmahLoggingTurnedOn="True" />
Update your connection string
<add name="elmah-sqlserver" connectionString="data source=XXXXXXXX;Integrated Security=True;;initial catalog=XXXXXX" providerName="System.Data.SqlClient" />
A lot of the is the default options but once I tinkered with the above settings I was able to get this up in running in just a couple of hours. I had zero experience with this before hand. In part two, I will be describing listing out all of the Sitefinity settings that I feel should be automatically included and the way to set them up without running the solution.