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

Posted

tags:

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

static string RenderViewToString(ControllerContext context,
                                    string viewPath,
                                    object model = null,
                                    bool partial = false)
{
    // first find the ViewEngine for this view
    ViewEngineResult viewEngineResult = null;
    if (partial)
        viewEngineResult = ViewEngines.Engines.FindPartialView( context, viewPath);
    else
        viewEngineResult = ViewEngines.Engines.FindView(context, viewPath, null);
      
    if (viewEngineResult == null)
        throw new FileNotFoundException("View cannot be found.");
      
    // get the view and attach the model to view data
    var view = viewEngineResult.View;
    context.Controller.ViewData.Model = model;
      
    string result = null;
      
    using (var sw = new StringWriter())
    {
        var ctx = new ViewContext(context, view,
                                    context.Controller.ViewData,
                                    context.Controller.TempData,
                                    sw);
        view.Render(ctx, sw);
        result = sw.ToString();
    }
      
    return result;
}

以上是关于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