Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Using Nancy 2 with Razor? #2839

Open
bonesoul opened this issue Dec 21, 2017 · 12 comments
Open

Using Nancy 2 with Razor? #2839

bonesoul opened this issue Dec 21, 2017 · 12 comments

Comments

@bonesoul
Copy link

I'm trying to get Nancy2 clinteastwood with Razor but couldn't find any guides for so? Any directions?

@jdixon-86
Copy link

I believe it is the same as Nancy1 as far as Razor is concerned. I would look at my issue here that others have experienced with Razor before going down that road though: #2731

@dealproc
Copy link

Been doing so (Razor/2.0.0-ClintEastwood).... been fine so far that I recollect. I have 1-2 things in production (internal-only systems) that have been fine.

@bonesoul
Copy link
Author

bonesoul commented Dec 26, 2017

I've been uzing Razor with 1.x series but have no idea how to do it with 2.x :/ Because i can't find propoper documentation for 2.x.

@jdixon-86
Copy link

@dealproc there is an issue when the application starts if there are multiple concurrent requests at the same time it can cause a deadlock situation because it caches an assembly that appears to be invalid. The issue is reproducible but I only run into customers complaining about it every 1-2 months on my end. Most know to recycle the application pool again.

@bonesoul what issue are you running into?

@bonesoul
Copy link
Author

I referenced Nancy.ViewEngines.Razor.

When i navigate to my webserver; cshtml files are not checked even;

Could not locate your error view! Details: 
Unable to locate requested view

 • Name: error
 • Root path: E:\Coding\CoiniumServ\build\bin\Debug\netcoreapp2.0\web\default
 • Supported extensions: 
  - sshtml
  - html
  - htm
 • Inspected locations: 
  - views//error-
  - views//error
  - /error-
  - /error
  - views/error-
  - views/error
  - error-
  - error

If you were expecting raw data back, make sure you set the 'Accept'-header of the request to correct format, for example 'application/json'

@bonesoul
Copy link
Author

bonesoul commented Dec 27, 2017

I'm trying to get Razor working with Nancy & dotnet core. Note that I'm using in-process nancy in an existing network server code not a new aspnet core website project.

@jdixon-86
Copy link

@bonesoul I have encountered this issue before. Basically it isn't recognizing the .cshtml extension. I'm trying to recall what it was but I think it had something to do with the System.Web.Razor not being set to Copy Local and the same for Nancy.ViewEngines.Razor.

I'm trying to look through my past issues for my project and finding where I documented what this was.

@bonesoul
Copy link
Author

bonesoul commented Jan 4, 2018

before nancy 2 & dotnet core update i was using this;

  <Target Name="AfterBuild">
    <Copy SourceFiles="$(SolutionDir)/packages/Nancy.Viewengines.Razor.1.4.3/BuildProviders/Nancy.ViewEngines.Razor.BuildProviders.dll" DestinationFolder="$(OutDir)" />
    <Copy SourceFiles="$(SolutionDir)/packages/Nancy.Viewengines.Razor.1.4.3/lib/net40/Nancy.ViewEngines.Razor.dll" DestinationFolder="$(OutDir)" />
  </Target>

changed it to

  <Target Name="Copy" AfterTargets="CoreCompile">
    <Copy SourceFiles="$(SolutionDir)/packages/nancy.viewengines.razor/2.0.0-clinteastwood/lib/net452/Nancy.ViewEngines.Razor.dll" DestinationFolder="$(OutDir)" />	
  </Target> 

but i can't find a BuildProviders folder in new 2.0.0-clienteastwood nancy.viewengines.razor package.

maybe related to this https://github.com/NancyFx/Nancy/blob/master/src/Nancy.ViewEngines.Razor/targets/Nancy.ViewEngines.Razor.targets

@bonesoul
Copy link
Author

bonesoul commented Jan 4, 2018

I've added the package for Nancy.ViewEngines.Razor.BuildProviders-clienteastwood but still no luck.

https://github.com/NancyFx/Nancy/tree/master/src/Nancy.ViewEngines.Razor.BuildProviders

@teedty1
Copy link

teedty1 commented Jun 26, 2019

I was able to get a Razor ViewEngine working in my .net core 2.2 project. If this is helpful to anyone please feel free to use it. Also, if anyone sees anything that I'm doing wrong I'd love to hear from you.

https://gist.github.com/teedty1/a505b2a4fb2c48658d127d5d4682628a

@JTrotta
Copy link

JTrotta commented Mar 2, 2020

Any news about this?
Still not working on dot net core 3.1

@grumpydev
Copy link
Member

@JTrotta did you look at what @teedty1 posted? Unless anyone volunteers to get this working it's unlikely this will ever be properly supported.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants