add a reference to assembly ‘System.Web.Extensions…

I was adding a ajax-enabled control on a page and suddenly having “… You must add a reference to assembly ‘System.Web.Extensions…” error. It complained that my website assembly does not have a reference to ‘System.Web.Extensions’ and it was true. Definitely, I added the reference to my project, but the compiled dll does not have it.

I googled a little bit. Some suggest that I need to install Microsoft Ajax framework 1.0. I did it long time ago, but I re-installed it. The problem persisted. One good document was Configuring ASP.Net Ajax. I noticed <control> section in the web.config

The <controls> Element

The <controls> element registers ASP.NET AJAX namespaces in the System.Web.Extensions assembly and maps the asp tag prefix as an alias for these namespaces. The controls in the ASP.NET AJAX namespaces can be referenced in a Web page with syntax such as the following:

First, I didn’t have ScriptManager. This was a silly mistake.

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

Second, I didn’t register tagPrefix for “asp”. I find this strange. asp prefix is the default one, and I wondered why I bother to do. It turned out that if you don’t have tagPrefix for “asp”, your web project does not reference system.web.extensions and it will break. So, please do.

<system.web>
  <pages>
    <controls>
      <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </controls>
  </pages>
</system.web>
add a reference to assembly ‘System.Web.Extensions…

One thought on “add a reference to assembly ‘System.Web.Extensions…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s