Cannot resolve symbol "ViewData" in AspNetCore project

Rider can't recognize "ViewData" variable in Razor views bun project successfully builds. How to solve this issue?


Hello, could you please check if this reproduced on the latest 2017.3 EAP build? We have fixed a bunch of similar issues recently.


Thanks Julia, this bug not appears on latest Rider version.


Good! Thanks for letting me know.


Am on the latest version of Resharper but it still gives me the error.


I am also having this same issue on 2017.3

I am making use of Razor Pages. It is also confused about the existence of @Model

Running on Mac


I am experiencing the same thing on 2017.3 #RD-173.3994.1125.

In addition to ViewData, it also thinks it cannot resolve "@model" and  "@inject


I too have the same issue.


Same thing here. It's been an issue for quite some time and it's getting tiresome.

I'm on VS 15.5.4 and it has been a problem for at least the last 4 releases of VS.


Same problem, using RD-173.3994.1125 (Ubuntu 17.10).

Renaming the file to something else and then back fixes it, but it is usually a large number of files.


Just in case anyone runs into this issue, I ran into and here is what I found:

Rider will display an error for ViewData if there is a space after the @model declaration.
This is the code in question:
@model main_web_core.Pages.Admin.PermissionsModel
ViewData["Title"] = "Permissions Management";

If you put the cursor at the end of the @model line above you will find 1 extra space - this is causing 'Cannot resolve Symbol ViewData'. Remove the space and the error disappears. This is not a compile time bug, simply shows up in Solution Wide Analysis.



Tab Hockamier thank you for that suggestion. In my case it was whitespace between generic arguments.

Page<BlogImplementation, PostImplementation> -> Rider Error (space after the comma)

Page<BlogImplementation,PostImplementation> -> No Error

Since the first variant is more common and readable this should definitely be fixed imo


thank you for the feedback.
I've filed a corresponding issue - You are welcome to comment or vote for it.


Same problem with latest version of Rider (2022.3.1 Build #RD-223.8214.53)

The problem is solved by editing the file (e.g. add and remove a space)


Alternative solution is to invalidate the caches, which will restart your Rider and re-analyze your project.

File -> Invalidate Caches... -> Invalidate and Restart

Thanks Michael Mickelson  it has been driving me bonkers for a few days.  


I had the same problem and for me the solution was actually to rename the "problem file(s)" and then rename it again to the original name.
This is of course a bug and annoying at that, but reasonably easy to fix
PS: Special thanks to Jepra 


Please sign in to leave a comment.