简体   繁体   English

ASP.NET Core 1.0中的服务器端自定义控件呈现

[英]Server side custom control rendering in ASP.NET Core 1.0

Anyone know good behavior for creating server side logic for render custrom control in ASP vNext? 任何人都知道在ASP vNext中创建用于渲染渲染控件的服务器端逻辑的良好行为吗? I read about tag helpers but i don't know that is the best solution for me. 我阅读了有关标签助手的信息,但我不知道这对我来说是最佳解决方案。 The expected end solution should look similar to: 预期的最终解决方案应类似于:

public class CustomControl : Control //here base class with context etc
{
    public override void Render()
    {
        using (var control = _context.Div())
        {
            input.AddAttribute(HtmlTextWriterAttribute.Content, "Div");
        }
    }
}

I'm looking for good documentation that help me implement base Control class. 我正在寻找可以帮助我实现基本Control类的好的文档。

Server side custom controls were a solution to a bad ASP.NET design. 服务器端自定义控件是不良ASP.NET设计的一种解决方案。 vNEXT is design to not have these same types of problems, and while you could try to reimplement the same bad design issues, you should instead look at using direct HTML rendering and / or JSON, and then let the browser handle the complications with something like HandlebarsJS vNEXT的设计没有这些类型的问题,尽管您可以尝试重新实现同样的不良设计问题,但应该改用直接HTML呈现和/或JSON,然后让浏览器通过类似的方式处理复杂性车把

also by offloading most of the work to the browser your server will be able to handle a far higher user load. 通过将大部分工作转移到浏览器,您的服务器将能够处理更高的用户负载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM