-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does this work with Razor views? #6796
Comments
Yes. https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/page?view=aspnetcore-2.1 shows it with MVC apps. |
Thanks for the quick reply! The examples in that document, though, are also for "Razor Pages". What I was trying to do was put a cshtml file in the library (under I guess the question would be better asked "Does this only work for Razor files with an |
Similar to @danieljsummers I can't get the RCL to work with View Component. I am getting an error saying that the view can't be found. I created a view component the way I usually do and added a view under Views/Shared/Components in the RCL project. The documentation is saying that RCL is suitable for view components and MVC style Razor pages. Is there an example for this ? @Rick-Anderson This is the folder structure for my RCL project. Nothing fancy. I added a reference to my MVC project that is consuming this class library. Based on my folder structure if there anything that I need to do to tell the MVC project where to look for the view ? |
@rahamohebbi create the simplest possible project that reproduces the problem and I'll see if I can get someone to look at it. I know it works with view components though. |
I've tried several different spots, but still can't make it. I've made a repro of it with 4 different patterns, none of which work. (This is low priority; I'm sure it's something I'm doing wrong, and I truly do appreciate the help.) |
BTW, I'd also be willing to strip it down further (remove JS and all that) and make a similar example as the one with the pages. |
@pranavkm can you comment on problems with VC's in RCLs? |
ASP.NET Core discovers view components from all registered application parts and |
@danieljsummers - try changing the name of your secondary project. The file name that the class library @rahamohebbi a repro app would help. |
@pranavkm That's it! :) Works like a charm now. Would this page be the right place for a warning about this? I'll do up a PR if so. |
@Rick-Anderson @pranavkm thanks The only difference i noticed was the RCL project file. copy pasted it to my existing class library and everything worked as it should. We might have some bugs there that needs to be ironed out. Cheers |
@rahamohebbi thanks for the update. |
@pranavkm can you respond to @danieljsummers
Is that worth warning about? |
While you're considering it, my thoughts were, under the "Create a class library containing Razor UI" heading:
OTOH, if the namespace collision shouldn't be an issue (i.e., a bug), then I'd think the doc either wouldn't need to be updated, or could be updated now, and then reverted once the fix is in place. |
@pranavkm can you comment on the suggestion by @danieljsummers ? |
This seems reasonable. Also, it's an issue with file name collision rather than a namespace collision. |
I'll get it turned tomorrow evening (Sunday) unless something comes up IRL. |
I ended up moving the bullet up 1 from my original suggestion, because the name of the project precedes the dialog that has the .NET Core 2.1 selection. I also spelled out "filename collision with the generated view library" vs. "namespace collision". |
This is a feature I've been wanting for quite some time. :) I've been trying to make it work by providing Razor views for use in an MVC application, but I'm having trouble getting that to work. From the description, it seems like it should work; am I reading correctly?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: