-
Notifications
You must be signed in to change notification settings - Fork 148
Setup ASP.NET MVC 3 or ASP.NET MVC 4 project
smikulenas edited this page Feb 25, 2013
·
28 revisions
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 = BetterCmsContext.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[] { "User", "Admin" });
HttpContext.Current.User = principal;
}
To use BetterCMS default page - updated your site routes configuration not to takeover site root path.
You need only to create database instance and update connection string in Web.config to point to it. All the necessary database structure (tables and etc.), will be created on application start.
Update Web.config file:
<runtime>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
[...]
</runtime>
Check if webpages version is setup with correct version.
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
[...]
<appSettings>
After all above configuration - CMS is ready for usage.