Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Mário Nunes 7 posts 87 karma points
    Jul 15, 2018 @ 16:33
    Mário Nunes

    Is it possible to load a View without setting the Template for the Document Type?


    Weird question!

    Is it possible to load a view without setting the template on the document type?

    If the template is not set, it always goes to 404 page and never enters the controller.

    I'm doing this because I don't want that specific view on the backoffice.


  • Rihab 84 posts 317 karma points
    Oct 28, 2019 @ 11:03

    Did you find a way yo do that? I'm facing the same problem

  • Mário Nunes 7 posts 87 karma points
    Nov 08, 2019 @ 09:09
    Mário Nunes

    Hey, what I ended up doing was registering a controller at runtime, like this:

               new { controller = "ControllerName", action = "ActionName" });

    Then on the controller:

     public ActionResult ActionName()
            BaseModel model = ... (here I just got my homepage IPublishedContent) since the model didn't matter, just needed it for the base layout;
            return View("~/path/to/view.cshtml", model);

    To note, I did all this on a different .csproj aside the main project, as an extensible plugin.

Please Sign in or register to post replies

Write your reply to: