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?


4
16 comments

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

1

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

0

Good! Thanks for letting me know.

0

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

0

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

0

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

2
Avatar
Permanently deleted user

I too have the same issue.

2

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.

0

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.

0

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:
@page
@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.

 

2

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

0

Hello,
thank you for the feedback.
I've filed a corresponding issue - https://youtrack.jetbrains.com/issue/RSRP-489965. You are welcome to comment or vote for it.

0

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)

0

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

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

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

0

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

0

Please sign in to leave a comment.