Question

Using Nancy and the Razor view engine I get the following situation. I have a view:

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase

<!DOCTYPE html>
<html>
    <head>
        <title></title>
    </head>
    <body>
        @Html.Partial("_PartialPage1")
    </body>
</html>

And a partial view containing:

   <strong>I am partial.</strong>

After running the application generated HTML looks like

<!DOCTYPE html>
<html>
    <head>
        <title></title>

    </head>
    <body>
        <div>
    <!DOCTYPE html>
<html>
    <head>
        <title></title>

    </head>
    <body>


<strong>I am partial.</strong>

</body>
</html>

</div>
    </body>
</html>

It seems as if the partial is rendered as a full HTML page instead of the snippet. Does anyone have an idea how to resolve this?

EDIT: I am using Nancy.Hosting.Aspnet.

UPDATE: I am using a _ViewStart.cshtml which seems to be applied to the partial view as well. Can this be prevented?

UPDATE: Files in the views folder

Views
  Default
    _ViewStart.cshtml
    Index.cshtml
  Partials
    _PartialPage.cshtml
  Shared
    _LayoutPage.cshtml

_ViewStart.cshtml contains the reference to the Layoutpage to be used.

@{
  Layout = "Views/Shared/_LayoutPage.cshtml";
}

The problem is that it is applied to the _PartialPage.cshtml as well. Independant of which folder the _ViewStart.cshtml is placed. I hope you can reproduce it like this.

Was it helpful?

Solution

So in short, when using Nancy/Razor de _ViewStart.cshtml is applied to all views, even partial views. Thank you Phill for clearing that up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top