The reason for this is that the anonymous type being passed in the controller in internal, so it can only be accessed from within the assembly in which it’s declared. Since views get compiled separately, the dynamic binder complains that it can’t go over that assembly boundary.
public abstract class BaseItem
{
public int Id { get; set; }
public string Title { get; set; }
public virtual IEnumerable<BaseItem> Childs { get; set; }
public BaseItem()
{
Childs = new List<BaseItem>();
}
}
public class Item : BaseItem
{
public new IEnumerable<Item> Childs { get; set; }
}
SearchResultCollection adSearchResult;
using (DirectoryEntry de = new DirectoryEntry("LDAP://esrr.oao.rzd"))
{
using (DirectorySearcher adSearch = new DirectorySearcher(de))
{
adSearch.Filter = $"(&(objectCategory=person)(objectClass=user)(name={searchString}*)(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2))";
//adSearch.PropertiesToLoad.Add("displayName");
adSearchResult = adSearch.FindAll();
}
}
public void ResetPassword(string userDn, string password)
{
DirectoryEntry uEntry = new DirectoryEntry(userDn);
uEntry.Invoke("SetPassword", new object[] { password });
uEntry.Properties["LockOutTime"].Value = 0; //unlock account
uEntry.Close();
}
public class UsersController
{
public ActionResult Index()
{
}
[Route("user/{id:int}")]
public ActionResult GetUserById(int id)
{
}
}
services.AddTransient<DdContext>()
,public PersonService(DbContext context)