How to register assembly in Razor view engine

2019-04-29 03:46发布

How can i insert this in razor view page

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>

<asp:ScriptManager runat="server" ID="MainScriptManager" />

4条回答
We Are One
2楼-- · 2019-04-29 04:01

To add new register in MVC, you can put in the web.config:

<configuration>

  <system.web>
    <pages>
      <controls>
        <add assembly="System.Web.Silverlight" namespace="System.Web.UI.SilverlightControls" tagPrefix="asp" />
      </controls>
    </pages>
  </system.web>

</configuration>
查看更多
在下西门庆
3楼-- · 2019-04-29 04:02

You can put it in the Web.Config that exists in your Views folder. It took me a while to figure this one out hope this helps.

<system.web>
  <controls>
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
    <add assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagPrefix="ajaxToolkit"  />
  </controls>
</system.web>
查看更多
太酷不给撩
4楼-- · 2019-04-29 04:16

you can try @using Namespace; where Namespace is what you need

查看更多
我只想做你的唯一
5楼-- · 2019-04-29 04:27

You cannot. You are using ASPX markup in your example. In razor you can write:

@using System.Web.Silverlight;

btw. check this syntax quickref:

查看更多
登录 后发表回答