GithubHelp home page GithubHelp logo

Comments (14)

nojaf avatar nojaf commented on July 23, 2024

What version are you on? I believe Giraffe used to use RazorLight instead of AspNetCoreMvc. So maybe you are using an older version of Giraffe and RazorLight doesn't use the concept of a ViewStart file.

Not sure though.

from giraffe.

vtquan avatar vtquan commented on July 23, 2024

I am using Giraffe 0.1.0-alpha025 and Giraffe.Razor 0.1.0-alpha001 which should be the latest version for both.

from giraffe.

nojaf avatar nojaf commented on July 23, 2024

I'm able to reproduce this, it doesn't work and there is not much to go on.
I'm guessing something is missing in the middleware but that is a wild guess.

from giraffe.

dustinmoris avatar dustinmoris commented on July 23, 2024

hey thanks for reporting this. I am currently working through the changes with the task changes that have been submitted via a PR and after that I'll pick this one up next!

from giraffe.

vtquan avatar vtquan commented on July 23, 2024

Good to know that you'll look into it. Thanks.

from giraffe.

EricDw avatar EricDw commented on July 23, 2024

I was able to use the

@renderpage("~/Views/_Header.cshtml")

Not sure if I have the wrong syntax or it is related.

I get a ""RenderPage" is out of context" error.

from giraffe.

EricDw avatar EricDw commented on July 23, 2024

Was not able to use*****

from giraffe.

EricDw avatar EricDw commented on July 23, 2024

I would like to clarify that the

@{ Layout = "_Layout"; }

Logic does indeed work for me.

As for the

@RenderPage("~/Views/SomeHtml.cshtml")

code, after reading the ASP.NET Core Razor docs I think I'm just using system incorrectly.

from giraffe.

nojaf avatar nojaf commented on July 23, 2024

@EricDw did you place the @{ Layout = "_Layout"; } inside the _ViewStart.cshtml file or in the view itself?

from giraffe.

EricDw avatar EricDw commented on July 23, 2024

@nojaf @{ Layout = "_Layout"; } is in the view itself. I am pretty sure that ASP.NET Core no longer uses @RenderPage instead I am using @{ await Html.RenderPartialAsync("_Header"); }
inside the _Layout.cshtml and it that does the job.

from giraffe.

nojaf avatar nojaf commented on July 23, 2024

Ok but I believe the original issue that @vtquan has is that setting the Layout from _ViewStart.cshtml doesn't work.
If he has a hundred views then setting the Layout from the view isn't really an option.

from giraffe.

vtquan avatar vtquan commented on July 23, 2024

@nojaf Yes, that is my issue.

from giraffe.

lukethenuke avatar lukethenuke commented on July 23, 2024

This is fixed by changing the isMainPage parameter to true in the call to IRazorViewEngine.FindView, I have opened a pull request with test and fix at #92 :)

from giraffe.

dustinmoris avatar dustinmoris commented on July 23, 2024

Thanks for the fix. I just released it with the newest NuGet package: Giraffe.Razor 0.1.0-beta-002!

from giraffe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.