csharp 来自http://www.codemag.com/Article/1312081

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 来自http://www.codemag.com/Article/1312081相关的知识,希望对你有一定的参考价值。

public static T CreateController<T>(RouteData routeData = null)
    where T : Controller, new()
{
    // create a disconnected controller instance
    T controller = new T();
      
    // get context wrapper from HttpContext if available
    HttpContextBase wrapper;
    if (System.Web.HttpContext.Current != null)
        wrapper = new HttpContextWrapper(System.Web.HttpContext.Current);
    else
        throw new InvalidOperationException(
            "Can't create Controller Context if no "+
            "active HttpContext instance is available.");
      
    if (routeData == null)
        routeData = new RouteData();
      
    // add the controller routing if not existing
    if (!routeData.Values.ContainsKey("controller") &&
        !routeData.Values.ContainsKey("Controller"))
        routeData.Values.Add("controller",
                             controller.GetType()
                                       .Name.ToLower() .Replace("controller", ""));
      
    controller.ControllerContext = new ControllerContext(wrapper, routeData, controller);
    return controller;
}

以上是关于csharp 来自http://www.codemag.com/Article/1312081的主要内容,如果未能解决你的问题,请参考以下文章

csharp 来自csvj的getFrameworkVersion在tfvc上

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp HMACSHA256来自http://ideone.com/JdpeL