What is @section scripts and what it is used for

前端 未结 4 1352
不知归路
不知归路 2021-01-31 02:21

I have downloaded a chat example from the Microsoft website. I have been following several tutorials but I have never seen the @section script{} before I have done scripts with

4条回答
  •  渐次进展
    2021-01-31 02:43

    A section allows you to add something in a view which will be added in the layout. ie:-

    view

    @section scripts {
    
        
    
    }
    

    layout

    @RenderSection("scripts", false)
    

    now this named section scripts will be rendered where you have specified in the layout.

    @RenderSection also has 2 signatures:-

    public HelperResult RenderSection(string name) // section required in the view
    public HelperResult RenderSection(string name, bool required)
    

提交回复
热议问题