This question is locked. New answers and comments are not allowed.
Hi:
No question, just my solution. The first thing to do in MVC or Asp.Net is to create your own base class. I added an empty controller called BaseController.
Now derive from your base controller class:
namespace Mvc3App.Controllers
{
public class HomeController : BaseController
{
The above works without being on every page, but I assume that it would crash if one did not go to the home controller first. But now one can add custom auth or logging, etc to this base page.
Phil
No question, just my solution. The first thing to do in MVC or Asp.Net is to create your own base class. I added an empty controller called BaseController.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;
namespace Mvc3App.Controllers
{
public class BaseController : Controller
{
//
/// <
summary
>
/// Base controller constructor
/// Handles:
/// 1) menu and Web.sitemap configuration
/// ...
/// </
summary
>
/// <
returns
>void</
returns
>
public BaseController()
{
if (!SiteMapManager.SiteMaps.ContainsKey("Web"))
{
SiteMapManager.SiteMaps.Register<
XmlSiteMap
>("Web", sitemap => sitemap.LoadFrom("~/Web.sitemap"));
var siteMap = SiteMapManager.SiteMaps["Web"];
ViewData["Web"] = siteMap;
}
}
}
}
Now derive from your base controller class:
namespace Mvc3App.Controllers
{
public class HomeController : BaseController
{
The above works without being on every page, but I assume that it would crash if one did not go to the home controller first. But now one can add custom auth or logging, etc to this base page.
Phil