I have 2 questions.
First, the background:
I have 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(); base.Initialize(rc); } }
I have a Site and PageConfiguration stored in PageController, because every page that implements PageController needs them
Question 1:
I am trying to port this from an existing ASP.NET application. what does the page name need to get a PageConfiguration object. Instead of the page name, I use the controller name instead. What is the best way for me to get this as a string?
Question 2:
I am trying to display a PartialView that relies on this 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 see that when the RenderPartial () method is called the PageConfiguration Model, I need a panel. But in the constructor for the Search class, which PanelConfiguration is null.
Is there a better and more efficient way to make the data I need for this page? Thanks.
source share