-
Notifications
You must be signed in to change notification settings - Fork 148
Setup ASP.NET MVC 3 or ASP.NET MVC 4 project
Prerequisites:
- ASP.NET MVC 3 or ASP.MVC 4 website project with .Net 4.0
In NuGet console paste the line below:
Install-Package BetterCMS -Pre
This will install into your website project BetterCMS NuGet package and all the dependent packages.
After successful BetterCMS package installation update your Global.asax.cs file with usings:
using System.Security.Principal;
using BetterCms.Core;
using BetterCms.Core.Environment.Host;
and code:
private static ICmsHost cmsHost;
protected void Application_Start()
{
cmsHost = CmsContext.RegisterHost();
// [YOUR CODE]
cmsHost.OnApplicationStart(this);
}
protected void Application_BeginRequest()
{
cmsHost.OnBeginRequest(this);
}
protected void Application_EndRequest()
{
cmsHost.OnEndRequest(this);
}
protected void Application_Error()
{
cmsHost.OnApplicationError(this);
}
protected void Application_End()
{
cmsHost.OnApplicationEnd(this);
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
var principal = new GenericPrincipal(
new GenericIdentity("TestUser"),
new[] {"BcmsEditContent", "BcmsPublishContent", "BcmsDeleteContent", "BcmsAdministration"});
HttpContext.Current.User = principal;
}
To use BetterCMS default page - update your site routes configuration not to takeover site root path, because default demo page will be installed under the root.
You need only to create database instance and update connection string in Web.config to point to it (use named instance called BetterCms). Accordingly update Config/cms.config tag <database [...]/> with correct information, too. All the necessary database structure (tables and etc.), will be created on application start.
Update Web.config file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
[...]
</assemblyBinding>
</runtime>
Check webpages version.
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
[...]
<appSettings>
After all above configuration - CMS is ready for usage.