MVC ViewComponent default view not resolved unless it is in the shared folder.


MVC ViewComponent default view is not resolved unless it is in the shared folder.

Source code is available in the following github repo. 

Just as an example in the M2-Intro-To-THs-And-VCs project 

placing the components folder in shared folder of views the view gets resolved.



thank you all for the feedback.

I've filed a corresponding bug report - Please follow it to get the latest updates on the issue.

Thank you.


I played a lot with the assembly attributes in JetBrains.Annotaions. They (at least used to) work with PartialViews and anything that has Controller{1} and Action{0}. However they won't work for ViewComponents. 

The funny thing is that when I use something like this:

[assembly: AspMvcPartialViewLocationFormat(@"/full-path-to-the-features-folder/ComponentFolderName/Default.cshtml")]

It will fix that component. And because it is hard coded to point to that component only, all other components try to point to the same Default.cshtml.

I wish {0} and {1} was working here like the way that they work in PartialViews 

[assembly: AspMvcPartialViewLocationFormat(@"/full-path-to-the-features-folder/{1}/Default.cshtml")]
[assembly: AspMvcPartialViewLocationFormat(@"/full-path-to-the-features-folder/{1}/{0}.cshtml")]




Also having this issue. Any default views for ViewComponents under the Shared folder work fine and return no errors. However, any ViewComponent with a default view not under the Shared folder flags an error.

~/Views/{Controller}/Components/{ViewComponent}/Default.cshtml <- produces an error

~/Views/Shared/Components/{ViewComponent}/Default.cshtml <- seems fine, no errors

The weird thing is, if I use the context menu to create the "missing" view, it creates it in my unit test project for some reason under ~/Pages/Components/{ViewComponent}/Default.cshtml

Any ideas?


Having the same issue with all our projects. I'ts reporting me over 1000 Errors that it cannot resolve the view "index" altough it IS there..

Really really annoying.

It's really had to figure out which error of this false positives is the real error ??:-(

We have our views organized like this:







and a viewlocationexpander is configured like this:

            // {0} - Action Name
            // {1} - Controller Name
            // {2} - Area name





Hello B Held

Could you please try clearing caches as described in the following article - and let us know if it helps?

Thank you.


Good morning. Sorry for late answer. I tried out clearing caches but this did not led to any change. Still over 1000 errors.


Hello B Held,

Thanks for the reply. It looks like you have an unusual structure here: "/Areas/{2}/{1}/Views/{0}.cshtml". This is why you get a lot of errors. We have the following issue about that, please comment or vote for it to get notifications about status changes. 

As a workaround, please use "Alt+Enter" on the problem view name and change the inspection severity ("Inspection: 'MVC' | Configure inspection severity"). Please let me know if you have any questions. Thank you!


B Held, I decided to submit a new issue in our bug tracker, so that each case is in a separate place. So, here it is. Please comment/vote for it. Thank you!


B Held are there ViewComponents not resolved in your project? Or regular views?


Please sign in to leave a comment.