views:

52

answers:

1

I need to render an ASP page to a string from an MVC controller action. I can use Server.Execute() to render a .aspx page, but not a .asp page.

Here's what I'm using:

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

which returns

`No http handler was found for request type 'GET'`

Any suggestions? I can do something similar with with a web request, but I'd rather avoid the overhead of a loopback request.

+1  A: 

Last time I checked, when running under an ASP.NET 3.5 or 4.0 context and using ASP.NET, Server.Execute isn't going to execute a .ASP page because there's no ASP.NET httpHandler configured for legacy .ASP pages.

What I would do is use a WebRequest to execute the .ASP page and store the results, then dump the string output of the response to a string and then dump that string when the controller method is executed. This way, you can even execute a .ASP page on a different server (Server.Execute is NOT farm-friendly!)

Kevin Hoffman
That's what I meant by "loopback request". It works, but obviously incurs some additional overhead.
David Lively