This is a migrated thread and some comments may be shown as answers.

[Solved] System.InvalidOperationException: You cannot call render more than once.

5 Answers 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chad Thiele
Top achievements
Rank 1
Chad Thiele asked on 15 Feb 2010, 12:03 PM
Here's the stacktrace I get for the error:

System.InvalidOperationException: You cannot call render more than once.


System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: You cannot call render more than once. 
   at Telerik.Web.Mvc.UI.StyleSheetRegistrar.Render() 
   at Telerik.Web.Mvc.UI.StyleSheetRegistrarBuilder.Render() 
   at ASP.views_shared_error_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) 
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) 
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) 
   at System.Web.UI.Control.Render(HtmlTextWriter writer) 
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) 
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) 
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) 
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) 
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) 
   at System.Web.UI.Page.Render(HtmlTextWriter writer) 
   at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) 
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) 
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) 
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) 
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
   --- End of inner exception stack trace --- 
   at System.Web.UI.Page.HandleError(Exception e) 
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
   at System.Web.UI.Page.ProcessRequest() 
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) 
   at System.Web.UI.Page.ProcessRequest(HttpContext context) 
   at ASP.views_shared_error_aspx.ProcessRequest(HttpContext context) 
   at System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext) 
   at System.Web.Mvc.WebFormView.RenderViewPage(ViewContext context, ViewPage page) 
   at System.Web.Mvc.WebFormView.Render(ViewContext viewContext, TextWriter writer) 
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) 
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) 
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) 
   at System.Web.Mvc.Controller.ExecuteCore() 
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) 
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) 
   at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) 
   at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) 
   at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) 
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 
 


IIS 6 Hosting in Medium Trust environment. What could be calling Render more than once? What scenarios would this be a potential issue from?

Thanks!


5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 15 Feb 2010, 12:46 PM
Hello Chad Thiele,

There is a similar forum thread which you can check here.

Greetings,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Chad Thiele
Top achievements
Rank 1
answered on 15 Feb 2010, 01:19 PM
I should of said I already saw that thread... no partial controls named the same as views...

Any ideas?
0
Atanas Korchev
Telerik team
answered on 15 Feb 2010, 02:57 PM
Hi Chad Thiele,

Do you have more than one stylesheet registrar? If so make sure that only the one in your master page is rendered (using <%= %> or by calling explicitly its Render() method). Any other stylesheet registrars should be used like this:

<% Html.Telerik().StylesheetRegistrar(); %>

Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Martin Aatmaa
Top achievements
Rank 1
answered on 10 Aug 2010, 01:22 AM
Hi Atanas,

I'm running into the same problem as Chad.

Here are my repro steps:

1) Execute an action that has a [HandleError] attribute attached. Return a ViewResult to render a View (say, /Views/Home/Index.aspx)

2) Configure the Index view to use a master page Site.Master.

3) In Site.Master, configure the Telerik asset control as normal:

Html.Telerik().StyleSheetRegistrar().Render();

4) Configure /Views/Shared/Error.aspx to use Site.Master as well

5) In the Index view, throw an exception

Expected result:

The Index view throws an error, which should be handled by HandleError, which should then render the Error view

Actual result:

All the above happens, but the exception Chad posts is still thrown, because StyleSheetRegistrar().Render() was called in Site.Master for the Index view, but it was also called in Site.Master for the Error view.

I haven't included the code here for the sake of brevity. If you need more details please let me know.
0
Martin Aatmaa
Top achievements
Rank 1
answered on 10 Aug 2010, 02:18 AM
As a temporary workaround, I have made the following modification, which involves creating a custom HandleErrorAttribute that clears the StyleSheetRegistrar as needed:

public class HackHandleErrorAttribute : HandleErrorAttribute
{
    public override void OnException(ExceptionContext context)
    {
        // Let the default Mvc framework OnException do it's thing
 
        base.OnException(context);
 
        filterContext.HttpContext.Items[typeof(Telerik.Web.Mvc.UI.ViewComponentFactory).AssemblyQualifiedName] = null;
        filterContext.HttpContext.Items[typeof(Telerik.Web.Mvc.UI.StyleSheetRegistrar).AssemblyQualifiedName] = null;
        filterContext.HttpContext.Items[typeof(Telerik.Web.Mvc.UI.ScriptRegistrar).AssemblyQualifiedName] = null;
    }
}

Ugly, but so far it works o_O
Tags
General Discussions
Asked by
Chad Thiele
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Chad Thiele
Top achievements
Rank 1
Martin Aatmaa
Top achievements
Rank 1
Share this question
or