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?


12 comments
Comment actions Permalink

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
Comment actions Permalink

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

0
Comment actions Permalink

Good! Thanks for letting me know.

0
Comment actions Permalink

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

0
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

I too have the same issue.

2
Comment actions Permalink

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
Comment actions Permalink

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
Comment actions Permalink

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.

 

1
Comment actions Permalink

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
Comment actions Permalink

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

Please sign in to leave a comment.