我想暴露WebClient.DownloadDataInternal方法,如下所示:
[ComVisible(true)]
public class MyWebClient : WebClient
{
private MethodInfo _DownloadDataInternal;
public MyWebClient()
{
_DownloadDataInternal = typeof(WebClient).GetMethod("DownloadDataInternal", BindingFlags.NonPublic | BindingFlags.Instance);
}
public byte[] DownloadDataInternal(Uri address, out WebRequest request)
{
_DownloadDataInternal.Invoke(this, new object[] { address, out request });
}
}
Run Code Online (Sandbox Code Playgroud)
WebClient.DownloadDataInternal有一个out参数,我不知道如何调用它.救命!
当我将SchemaExport与SQL Server 2005一起使用时,它会生成唯一的密钥名称,如:
UQ__Employees__03317E3D
如何生成如下名称:UQ__Employees__Name?即使在SQL Server中!
我写了一个如下控制器:
public class AccountController : Controller
{
public ActionResult Login(/*---*/)
{
GenericIdentity identity = new GenericIdentity("userName");
GenericPrincipal principal = new GenericPrincipal(identity, new string[] { "role1", "role2" });
this.HttpContext.User = principal;
/*---*/;
}
}
Run Code Online (Sandbox Code Playgroud)
登录后,我可以通过其他控制器中的User.Identity.Name获取用户名.但User.IsInRole("role1")始终返回false.
如何为User分配值,我不想使用Membership ...