StackExchange / StackExchange.Precompilation

Roslyn based csc.exe and aspnet_compiler.exe replacement with metaprogramming hooks for ASP.NET MVC projects from the pre-DNX era
MIT License
155 stars 37 forks source link

Cannot resolve partial views in different paths #6

Closed tompazourek closed 8 years ago

tompazourek commented 8 years ago

I found out that the precompiled view engine cannot resolve partial views in different folders.

How to reproduce the issue:

  1. Use Test.WebApp from the source code
  2. Comment out fallback to RoslynRazorViewEngine in Global.asax.cs
  3. Add partial view to Views/OtherFolder/_PartialTest.cshtml (you'll need to create OtherFolder directory inside Views first)
  4. Inside Views/Home/Index.cshtml call @Html.Partial("../OtherFolder/_PartialTest")
  5. Build in Release mode
  6. Launch web app and crash

capture

m0sa commented 8 years ago

Thanks for the report. Looking into it. The issue is with relative paths, @Html.Partial("~/Views/OtherFolder/_PartialTest.cshtml") work just fine.

tompazourek commented 8 years ago

Thanks for quick response!

I've had some problems with the absolute paths as well, but it might be some other issue. I will have to try it once again.

tompazourek commented 8 years ago

Thanks for a quick fix. I've checked and it seems alright now.

The problem I was having with absolute paths was the missing file extension in my path, so not really related to this.

I would love to see this on NuGet whenever convenient.