Server.Transfer redirects from the sender page, and sometimes you want
specifically to execute code while remaining where you were.
But regardless of this, it returns the same error - Exception Details:
System.Web.HttpException: Error executing child request for ztest.asp.
But this leads to the question of why you would want to execute ASP code
in an ASP.NET application.
Before you answer this, think a bit. If you want to just skip ahead, I
will show you a better way.
Ready?
If you have a lot of ASP code that cannot easily be moved and you
"have" to execute it, move the code to a classic VB COM component. you
still deal with interop and have to rewrite a bit of UI code, but you
avoid kludging up ASP.NET to hold on to legacy ASP.
I understand the main argument against this, which is time and
investment, but kludging up a system has many ill effects that overrule
the time argument and chasing sunk costs is just plain stupid.
I would also argue that having all that code in an ASP page is insane. I
know the insanity is common (even in ASP.NET, where pages often contain
the entire app, as well), but common does not mean right.
Now, you might answer "but the time it takes to move the code to VB is
just as long as rewriting in ASP.NET". Bingo. You get the point. ;-)
System.Diagnostics.Process.Start might eventually work as a solution,
but it appears it needs extra server settings due to a different error
(below)
Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the
required permission please contact your system administrator or change
the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request failed.
This is to be expected, as you are stepping out of the apartment, or
"crossing a process boundary". You more commonly see this error when you
try to run system processes (outside of the web folders) from a web
page. The sane solution to this problem is wrap the system process in a
service that has a front end you can connect to (WCF works, for
example).
In this case, you see the error not because of running outside of the
web folder, but running outside of the ASP.NET worker process.
Either way, it is a wrongheaded solution, as ASP is run under the IIS
process (like ASP.NET) and not as a separate process. You might be able
to kludge it and make it work, if you want to earn a geek brass ring,
but it would be a nice mental exercise and not a practical solution.
Peace and Grace,
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Twitter: @gbworld
Blog:
http://gregorybeamer.spaces.live.com
My vacation and childhood cancer awareness site:
http://www.crazycancertour.com
*******************************************
| Think outside the box! |
*******************************************