Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is related to the fact that in case of a virtual view, a view whose content is retrieved from a file or database, inherits from <code>System.Web.Mvc.ViewStartPage</code> that contains Html and Url, but doesn't ViewBag or Ajax properties. The virtual view is referred as follows</p> <pre><code>public class DynamicViewsController : Controller { public ActionResult GetView() { //SomeModel model = new SomeModel() { Count = 1 }; return View("/Virtual/VirtualViewToShow.cshtml"); } } </code></pre> <p>A view located in ~/Views/ folder inherits from System.Web.Mvc.WebViewPage, which has ViewBag and ViewData, and Ajax properties defined.</p> <p>The workaround to change the action method as follow </p> <pre><code>public PartialViewResult GetView() { //SomeModel model = new SomeModel() { Count = 1 }; return PartialView("/Virtual/VirtualViewToShow.cshtml"); } </code></pre> <p>and to add </p> <pre><code> @{ Layout = "~/Views/Shared/_Layout.cshtml"; } </code></pre> <p>to the text of the virtual view in order to load the layout also. I don't know the reason why a virtual view inherits from <code>System.Web.Mvc.ViewStartPage</code>, but I'll try to find the reason for this in another thread and will post the link when thre thread is created.</p> <p><strong>Edited</strong></p> <p>So a said the link to the new created thread is <a href="https://stackoverflow.com/questions/13363273/virtual-view-inheriting-from-system-web-mvc-viewstartpage">here</a></p> <p>"Show Complete Compilation Source" screenshot attached<img src="https://i.stack.imgur.com/WcySw.png" alt="enter image description here"></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.
    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