Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In short, its your Invoke() method! The razor engine works by writing to an in memory stream, and then parses it to the response. The reason you are getting that behaviour is because your Invoke() method is writing straight to the response stream; i.e. before the in memory stream is parsed.</p> <p>I came across similar behaviour when using the Html.RenderAction(), which pointed to an action that returned a PartialView. The workaround was to use Html.Action(). The difference being is that Action() returns a string which gets appended to the in memory stream, and RenderAction() writes to the directly to the response.</p> <p>If you post the code for your Invoke() method, I may be able to help you futher!</p> <p>| -- Edit -- |</p> <p>OK, this turned out to be more complex that initially anticipated. The problem is that I could not get ProcessRequest() to append to the current response; however, I may have a solution.</p> <pre><code>public string ProcessRoute(ViewContext viewContext, RouteData routeData) { var urlHelper = new UrlHelper(viewContext.RequestContext); var currentUrl = urlHelper.Action(routeData.Values["action"].ToString(), routeData.Values["controller"].ToString(), routeData.DataTokens); var stringWriter = new StringWriter(); var simpleWorkerRequest = new SimpleWorkerRequest(currentUrl, "", stringWriter); var context = new HttpContext(simpleWorkerRequest); var contextBase = new HttpContextWrapper(context); var requestContext = new RequestContext(contextBase, routeData); var httpHandler = routeData.RouteHandler.GetHttpHandler(requestContext); httpHandler.ProcessRequest(context); context.Response.End(); stringWriter.Flush(); return stringWriter.GetStringBuilder().ToString(); } </code></pre> <p>The code above generates a new Request and returns the Request's HTML as a string. By doing this, the result is appended as part of the current response. You can now rewrite your Invoke() function to return a string, which can be displayed on your View.</p> <pre><code>public string Invoke(ViewContext viewContext) { if (_mvcHandler == null) { var routeData = new RouteData(context.RouteData.Route, context.RouteData.RouteHandler); routeData.Values.Add("id", _id); routeData.Values.Add("moduleName", _moduleName); routeData.Values.Add("controller", _controllerName); routeData.Values.Add("action", _actionName); routeData.Values.Add("pageContext", _pageContext); if (!string.IsNullOrEmpty(_preferredNamespace)) { routeData.DataTokens.Add("Namespaces", new[] { _preferredNamespace }); } return ProcessRoute(viewContext, routeData); } return string.Empty; } </code></pre> <p>You may also have to change;</p> <pre><code>mr.Invoke(ViewContext); </code></pre> <p>To;</p> <pre><code>Html.Raw(mr.Invoke(ViewContext)); </code></pre> <p>In order stop the HTML encoding behaviour.</p> <p>| -- Note -- |</p> <p>Since I don't have your ModuleRequests class, I couldn't test this code specifically for your scenario. Instead, I replicated the problem as best as I could and solved it.</p> <p>Please let me know if you have any questions.</p> <p>Matt</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload