New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Unauthorized Access (401) Error

Environment

Product Progress® Telerik® UI for ASP.NET AJAX

Description

When working with Telerik UI for ASP.NET AJAX, I get an unauthorized access error (401).

Cause

When your project uses a form of authentication, for example, Windows Authentication, access to most resources, such as pages, images, and handlers, is not allowed for anonymous (unauthorized) users. This affects the Telerik controls because they use a number of HTTP Handlers that also get blocked.

Solution

To solve this issue, use either of the following approaches:

  • Use the CDNs Telerik provides for scripts and skins, and the MS AJAX CDN so that WebResources are used as rarely as possible. As a result, only some dialogs and the binary image and file uploads will keep using WebResources.

    You can also use a single request for all scripts and a combined base stylesheet request to greatly reduce the number of network requests.

  • Alternatively, add <location> elements to your web.config for all the handlers you use, so that ASP.NET does not block them. For example:

    web.config

    <configuration>
      ...
      <location path="Telerik.Web.UI.WebResource.axd">
        <system.web>
          <authorization>
        <allow users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="Telerik.Web.UI.DialogHandler.aspx">
        <system.web>
          <authorization>
        <allow users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="ScriptResource.axd">
        <system.web>
          <authorization>
        <allow users="*"/>
          </authorization>
        </system.web>
      </location>
      <location path="WebResource.axd">
        <system.web>
          <authorization>
        <allow users="*"/>
          </authorization>
        </system.web>
      </location>
      ...
    </configuration>
    
In this article