views:

317

answers:

1

I am building a version of the MVC Storefront. I have two themes, one is the standard ui, and the other is the admin ui. I have some HTML Helper methods, which deliver .ascx files to the .aspx files just like the example, but without plug-ins. All the stuff works on the default theme, but none of it works in the admin theme. I always get the same error when the Html.SimpleActivityTypeList() fires. The Html.RenderPartial(“AdminLeftNav”) will always work fine.

<asp:Content ID="Content3" ContentPlaceHolderID="NavContent" runat="server">
    <% Html.SimpleActivityTypeList(); %>
    <% Html.RenderPartial("AdminLeftNav"); %>
</asp:Content>

I have added a method as below to an extension class.

public static void SimpleActivityTypeList(this HtmlHelper helper)
    {
        helper.RenderAction<CatalogController>(x => x.SimpleActivityTypeList());
     }

And as I said this works fine in the default theme. Please Help?

Stack Trace: 


[ArgumentNullException: Value cannot be null.
Parameter name: httpContext]
   System.Web.Routing.RequestContext..ctor(HttpContextBase httpContext, RouteData routeData) +85
   Microsoft.Web.Mvc.ViewExtensions.RenderRoute(HtmlHelper helper, RouteValueDictionary values) +367
   Microsoft.Web.Mvc.ViewExtensions.RenderAction(HtmlHelper helper, Expression`1 action) +113
   GrandGuide.Web.CMSExtensions.SimpleActivityTypeList(HtmlHelper helper) in C:\S3_Depot\S3_Dev\GrandGuide\GrandGuide.Web\Infrastructure\Helpers\CMSExtensions.cs:55
   ASP.views_themes_admin_index_aspx.__RenderContent3(HtmlTextWriter __w, Control parameterContainer) in c:\S3_Depot\S3_Dev\GrandGuide\GrandGuide.Web\Views\Themes\Admin\Index.aspx:7
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   ASP.views_themes_admin_theme_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\S3_Depot\S3_Dev\GrandGuide\GrandGuide.Web\Views\Themes\Admin\Theme.Master:33
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +71
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
A: 

More info would help. In the past, I've used:

if (null != HttpContext)

or, if you're accessing something in the context such as a Session Variable:

if (null != HttpContext.Current.Session["my_var"])
pixelbobby
Thank you for the suggestion. I can do as you have written, but the real goal would be to never have a null context. I am using a custom view engine, which inspects a property on the controller to identify the appropriate ui theme, and master page file, to use.
Alpinfish