EmbeddedResourceVirtualPathProvider
EmbeddedResourceVirtualPathProvider copied to clipboard
Using "Enabling debugging for embedded razor views" doesn't works
When I used the technique described in "Enabling debugging for embedded razor views". If I put a breakpoint on the host constructor when a embedded Razor page is called, GetResourceFromVirtualPath() does return me a resource but resource.Filename is always null.
Hmm, that doesn't sound right...
Does the VPP actually work? Can you debug the Razor views?
The VPP works fine. But it seems all my embedded resources have no filenames. If I put a breakpoint on the MyCustomRazorHost constructor and look at System.Web.Hosting.HostingEnvironment.VirtualPathProvider and I can see all my resources but they all have null filenames.
So PhysicalPath is always set to null for embedded resources and therefore the debugging of embedded Razor views doesn't seem to work in my case.
Are you a. trying to debug embedded views in a project in the same solution (so the source files are available b. trying to debug embedded views in an assembly where the source files aren't present on disk?
I think a. works (or worked, I haven't done this recently) and b. is unknown territory. Maybe (when in debug) the files should be extracted into a temp folder and that path used for FileName...
Hi there,
I am also having this problem - was there any further progress on this from the above? Happy enough to investigate this if this is a known issue.
Hi, On my side I had to drop VPP altogether since they don't work with pre-compiled Razor views so I haven't dug further into the question.
Hi,
I've actually figured it out and it was an issue on my end - it will only return the filename if you populate the ProjectSourcePath parameter when registering the assembly with the Vpp class.
So adding in the custom factory in the steps provided here is now working for me.
However, there is an issue - using a custom razor factory appears to completely break intellisense in razor views in the MVC project.