EmbeddedResourceVirtualPathProvider icon indicating copy to clipboard operation
EmbeddedResourceVirtualPathProvider copied to clipboard

Using "Enabling debugging for embedded razor views" doesn't works

Open fnicollier opened this issue 8 years ago • 6 comments

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.

fnicollier avatar Nov 23 '16 09:11 fnicollier

Hmm, that doesn't sound right...

Does the VPP actually work? Can you debug the Razor views?

mcintyre321 avatar Nov 24 '16 16:11 mcintyre321

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.

fnicollier avatar Nov 30 '16 12:11 fnicollier

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...

mcintyre321 avatar Nov 30 '16 15:11 mcintyre321

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.

pkmckay147 avatar May 17 '17 14:05 pkmckay147

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.

fnicollier avatar May 17 '17 14:05 fnicollier

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.

pkmckay147 avatar May 17 '17 15:05 pkmckay147