Search code examples
asp.net-mvcrazorweb-controls

MVC ASPX To Razor - Register webcontrol


I converted my MVC 3 project from to aspx to razor, having a problem with this line: ASPX:

<%@ Register TagPrefix="cc1" Namespace="WebControlCaptcha" Assembly="WebControlCaptcha" %>

Razor:

@{
Register TagPrefix="cc1" Namespace="WebControlCaptcha" Assembly="WebControlCaptcha";
} 

Here is the error:

Compiler Error Message: CS1002: ; expected

Thanks in advance.


Solution

  • You can put, in the web.config inside Views folder, the following key:

    <configuration>
    
      <system.web>
        <pages>
          <controls>
            <add assembly="WebControlCaptcha" namespace="WebControlCaptcha" tagPrefix="cc1" />
          </controls>
        </pages>
      </system.web>
    
    </configuration>