Sep 14, 2014, 1:49 PM
[CLOSED] [#549] Rendering Partial View Error
Hi
I am calling a partial view from an external project using MvcRazorgenerator tool. I am getting the following error when i load the partial through my action in the controller.
Unable to cast object of type 'RazorGenerator.Mvc.PrecompiledMvcView' to type 'System.Web.Mvc.WebFormView'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'RazorGenerator.Mvc.PrecompiledMvcView' to type 'System.Web.Mvc.WebFormView'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidCastException: Unable to cast object of type 'RazorGenerator.Mvc.PrecompiledMvcView' to type 'System.Web.Mvc.WebFormView'.]
Ext.Net.MVC.PartialViewResult.ExecuteResult(Contro llerContext context) +2553
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResult(ControllerContext controllerContext, ActionResult actionResult) +39
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInv okeAction>b__1c() +321
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInv okeAction>b__1e(IAsyncResult asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndD elegate(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End( ) +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker. EndInvokeAction(IAsyncResult asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d( IAsyncResult asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDel egate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End( ) +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncRes ult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsy ncResult asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDel egate(IAsyncResult asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End( ) +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAs yncController.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__ 5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDel egate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End( ) +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsync Result asyncResult) +40
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHan dler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication.IExecutionStep.Execute() +9651188
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +155
Controller Code - this is called from a JS file that add a tab to main Tab control called pnlCenter
Any suggestions. Do I need to create my own partialViewExecute method. Thanks
I am calling a partial view from an external project using MvcRazorgenerator tool. I am getting the following error when i load the partial through my action in the controller.
Unable to cast object of type 'RazorGenerator.Mvc.PrecompiledMvcView' to type 'System.Web.Mvc.WebFormView'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'RazorGenerator.Mvc.PrecompiledMvcView' to type 'System.Web.Mvc.WebFormView'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidCastException: Unable to cast object of type 'RazorGenerator.Mvc.PrecompiledMvcView' to type 'System.Web.Mvc.WebFormView'.]
Ext.Net.MVC.PartialViewResult.ExecuteResult(Contro llerContext context) +2553
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResult(ControllerContext controllerContext, ActionResult actionResult) +39
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActio nResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInv okeAction>b__1c() +321
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInv okeAction>b__1e(IAsyncResult asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndD elegate(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End( ) +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker. EndInvokeAction(IAsyncResult asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d( IAsyncResult asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDel egate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End( ) +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncRes ult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsy ncResult asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDel egate(IAsyncResult asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End( ) +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAs yncController.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__ 5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDel egate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End( ) +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsync Result asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsync Result asyncResult) +40
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHan dler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication.IExecutionStep.Execute() +9651188
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +155
public Ext.Net.MVC.PartialViewResult Test()
{
RazorGenerator.Mvc.PrecompiledMvcEngine eng = this.ViewEngineCollection[0] as RazorGenerator.Mvc.PrecompiledMvcEngine;
RazorGenerator.Mvc.PrecompiledMvcView v = eng.FindPartialView(this.ControllerContext, "Test", false).View as RazorGenerator.Mvc.PrecompiledMvcView;
// view is loaded via ajax request (DirectEvent) therefore script tags will be deactivated automatically
var result = new Ext.Net.MVC.PartialViewResult
{
View = v,
//ViewName = "Test",
ContainerId = "plnCenter",
RenderMode = RenderMode.AddTo
};
return result;
}
View called Test - Please note that if I remove the panel and just have html code. the view loads fine from the external project. Also loading a partial view from my main application loads fine.@using SDRMA.Core.Web
@using System.Web.Optimization;
@using Ext.Net;
@using Ext.Net.MVC;
@{
ViewBag.Title = "Test Module";
//Layout = "~/Views/Shared/_Layout.cshtml";
Layout = null;
}
@(
Html.X().Panel()
.Title(DateTime.Now.ToLongTimeString())
.Closable(true)
.Layout(LayoutType.Fit)
.Html(
@<text>
<h1>HOME MODULE AREA</h1>
<h2>Hello! This is a Razor View that is loaded from an external project/assembly.<br /><br />(PluginHome - test page)</h2>
</text>
)
)
please note that it is trying to cast to System.Web.Mvc.WebFormView' when it should be using razorengine. WebformEngine is turned off.Any suggestions. Do I need to create my own partialViewExecute method. Thanks
Last edited by Daniil; Oct 01, 2014 at 12:37 PM.
Reason: [CLOSED]