Monday, March 23, 2009

Enable ASP debugging in an ASP.NET 3.5 Site

Today I got this error on an ASP running under Visual Studio 2008.

image

The error text was as follows:

The type of page you have requested is not served because it has been explicitly forbidden.  The extension '.asp' may be incorrect.   Please review the URL below and make sure that it is spelled correctly.

It turns out that ASP is not supported under Visual Studio 2008 unless you make 2 additions to the local Web.Config file. 

<compilation debug="false">
      <buildProviders>
        <add extension=".asp" type="System.Web.Compilation.PageBuildProvider" />
      </buildProviders>

</compilation>

 

<httpHandlers>
<add path="*.asp" verb="*" type="System.Web.UI.PageHandlerFactory" validate="true" />
</httpHandlers>

This will enable ASP to work in the debug browser however if you have relative paths it won’t work as you’re running only one project under a specific port number.

i.e You will get this type of error.

image

Alternatively you can just set the server in the project properties to run under local IIS, which is just as good.

image