Aspnetcore.docs: Remote validation - missing using

Created on 22 Feb 2019  Â·  3Comments  Â·  Source: dotnet/AspNetCore.Docs

I'm trying to add remote validation to my class but I got an error:
[Remote(controller: "Vendors", action: "ValidateCode", ErrorMessage = "Code already exists!")]
public string Code { get; set; }

Error:CS0246 The type or namespace name 'Remote' could not be found (are you missing a using directive or an assembly reference?)

Help please?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P2 Source - Docs.ms

All 3 comments

RemoteAttribute is in the Microsoft.AspNetCore.Mvc namespace, so you will need a using directive for this:

using Microsoft.AspNetCore.Mvc;

If you're not using the Microsoft.AspNetCore.App or Microsoft.AspNetCore.All metapackages in your project, you might also need a reference to the Microsoft.AspNetCore.Mvc.ViewFeatures nuget package.

Hi
Thank you for your answer. I was using Microsoft.AspNetCore.App and the RemoteAttribute library is not there, I had to install Microsoft.AspNetCore.All and everything is ok now.

Regards

I have same issue, and after I reference to the Microsoft.AspNetCore.Mvc.ViewFeatures nuget package, the issue has been solved, thanks!

Was this page helpful?
0 / 5 - 0 ratings