Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Views names are Case-Sensitive when precompiled but not at development time. #42

Closed
NTaylorMullen opened this issue Dec 8, 2016 · 7 comments

Comments

@NTaylorMullen
Copy link
Contributor

From @Bartmax on December 8, 2016 8:49

return View("MyView.cshtml")

with a file called Myview.cshtml will work with no problem on Windows in development.

it will fail on publish.

Maybe it would be good to enforce case-sensitive when loading views from disk ?

Copied from original issue: aspnet/RazorTooling#115

@NTaylorMullen
Copy link
Contributor Author

/cc @pranavkm

@pranavkm
Copy link
Contributor

pranavkm commented Dec 8, 2016

Dup of #37 which we decided was by design.

@Bartmax
Copy link

Bartmax commented Dec 8, 2016

Yes this is a dup in a sense of the issue, but have you considered having the FileProvider being case-sensitive by default ? So we can fail fast and avoid pitfall of errors.

I'm confident that will be a good thing. cc @pranavkm

@pranavkm
Copy link
Contributor

pranavkm commented Dec 8, 2016

@Bartmax we've had some discussions about this in the past (for instance aspnet/FileSystem#16 (comment)), and we don't want to enforce this behavior using the default PhysicalFileProvider implementation. You could do something like this at the application level by replacing the IHostingEnvironment.ContentRootFileProvider with a provider that enforces casing in Startup (https://github.com/aspnet/Hosting/blob/b6da89f54cff11474f17486cdc55c2f21f2bbd6b/test/Microsoft.AspNetCore.Hosting.Tests/Fakes/StartupWithHostingEnvironment.cs#L8-L11).

@Bartmax
Copy link

Bartmax commented Dec 8, 2016

I see, I think docs will be explicit about the file casing when using precompilation. That will solve most of the problems. (i think).

One more last question: Is there any OTB FileProvider that is case-sensitive (or can be configured as such) that I can use to replace for the ContentRootFileProvider ?

@pranavkm
Copy link
Contributor

pranavkm commented Dec 8, 2016

One more last question: Is there any OTB FileProvider that is case-sensitive (or can be configured as such) that I can use to replace for the ContentRootFileProvider ?

Not that I know of. There's a stackoverflow post about verifying paths on Windows using P/Invoke: http://stackoverflow.com/questions/16183788/case-sensitive-directory-exists-file-exists

@Bartmax
Copy link

Bartmax commented Dec 8, 2016

I see this is a very hard problem and understand why it wasn't addressed. We must have to live with good documentation and that's it. Thank you @pranavkm very insightful

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

No branches or pull requests

3 participants