1
votes

In my Asp.Net MVC5 Controller I am trying to run the following code to execute a classic asp script:

  public ActionResult Index()
  {
    Server.Execute("~/classic/test.asp");
    return new EmptyResult();
  }

But get the said error message. I've tried changing the /classic/ folder both as it's own application (pool) and as a normal folder, but same error. I've also checked the HTTP Handler Mappings in IIS for the .net site, and .asp is a recognized handler, so, it's definitely in there. Maybe there is a way to do a URL Rewrite method that will let you execute any script in it's place? It appears there is no ASP.NET httpHandler configured for legacy .ASP pages, but maybe that can be changed?

Does anyone know how to run a classic asp script through a controller, without using a WebRequest? It's possible using a WebRequest but it's also more overhead than desired.

You would think Microsoft would give this type of feature for people trying to migrate, I sure hope so.

2
What error message it shows? - rufanov
Can you use Server.TransferRequest() instead? - Rowan Freeman
Have you enabled 32 bit applications in your application pool? - Vogel612
@RowanFreeman That worked nicely, just checking if this does a redirect instead of direct render to page. Also, I put this in the view instead of controller, it works! You can post answer so I can accept. - Control Freak
@RowanFreeman It does not do a redirect, and works. You have the best answer. - Control Freak

2 Answers

2
votes

Use Server.TransferRequest() in the View instead of controller. Like this:

View:

@{Server.TransferRequest("~/classic/test.asp");}

It will render the classic ASP page as you expect.

0
votes

I solved the error message "No http handler was found for request type 'GET'" with another function from System.Web.HttpResponse and changing the web.config file.

Example:

Response.WriteFile("~/include/head.shtml");

 <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>

To use Server.Execute("~/include/head.shtml") I should change the application pool on IIS to

"Asp.Net v4.0 Classic"

.