0

Is it possible to get action name of System.Web.Mvc.RemoteAttribute object. (Initialized at constructor stage)

GetUrl() method and RouteData property are protected. Are there any hints?

4

1 回答 1

0

通过反射,您可以获得受保护的属性。我认为更好的解决方案是创建一个从 RemoteAttribute 派生的新属性类,并添加一些返回 Url 和 RouteData 的公共方法/属性。例如:

public class MyRemoteAttribute: System.Web.Mvc.RemoteAttribute
{
  public string GetUrlPublic()
  {
    return this.GetUrl();
  }
  public RouteValueDictionary GetRouteData()
  {
    return this.RouteData;
  }
}
于 2013-08-26T18:37:45.627 回答