2

When i add [Remote()] attribute to a class property, the following exception gets throw:

TypeLoadException: Could not load type 'System.Web.Routing.RouteValueDictionary' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Entities
{
    [Serializable]
    public class EmployeeEntity
    {
        public int Id { get; set; }
        
        [Required(ErrorMessage = "Required")]
        [MaxLength(20)]
        [RegularExpression(@"^\S*$", ErrorMessage = "No white space allowed")]
        [Remote("IsUserNameAvailable", "Employee",HttpMethod ="GET", ErrorMessage = "EmailId already exists in database.")]



Mosia Thabo
  • 4,009
  • 1
  • 14
  • 24
  • `System.Web.Routing` assemly doesn't seem to be available. Can you try add it using web.config file? Here's how: https://stackoverflow.com/questions/2828393/cs0012-the-type-system-web-routing-routevaluedictionary-is-defined-in-an-asse – Mosia Thabo Sep 02 '20 at 10:44
  • You said you use asp.net core,but why did you use `System.Web.Mvc`?It is the dll in asp.net. – Rena Sep 03 '20 at 02:36
  • Thank you Mosia that's working after i install Microsoft.AspNetCoreCore.Routing. – ismail haroun Sep 03 '20 at 06:06

1 Answers1

1

Solved - After i install Microsoft.AspNetCoreCore.Routing. The problem is using System.Web.Mvc in asp core project