I have 2 questions.
First, background:
I have a PageController : Controller
and SearchController : PageController
PageController is defined as:
public class PageController : Controller
{
protected ISite Site;
protected PageConfiguration PageConfiguration;
protected override void Initialize(RequestContext rc)
{
this.Site = new Site(SessionUser.Instance().SiteId);
this.PageConfiguration = this.Site.CurrentSite.GetPage(/* controller name */);
base.Initialize(rc);
}
}
I have Site & PageConfiguration stored in PageController because every page that implements PageController needs them
Question 1:
I'm trying to port this from an existing ASP.NET app. that requires a page name to get the PageConfiguration object. Instead of a page name, I'm going to use the Controller's name instead. What's the best way for me to get that as a string?
Question 2:
I'm trying to render a PartialView which relies on that data, as follows:
<%@ Page Title=""
Language="C#"
MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<PageConfiguration>" %>
<%@ Import Namespace="tstFactsheetGenerator.Models.Panels"%>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% Html.RenderPartial("Search", new Search { PanelConfiguration = Model.Panels[0] }); %>
</asp:Content>
I can see that when the RenderPartial() method is called the PageConfiguration Model has has the Panel I need. But in the constructor for the Search class that PanelConfiguration is null.
Is there a better & more effective way to make the data I need for the page available? Thanks.