Re: How may I implement this functionality using ASP.Net ?
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Sun, 25 Feb 2007 03:42:22 +0100
Bit Byte wrote:
I have an existing application which consists of a C++ frontend, and a PHP backend. I am currently contemplating moving from PHP to ASP.Net at the server side. At the server side, I have code somewhat like this:
<?
// function definitions here ...
$enc_str = base64_decode($_POST['request']);
$xml_str = mcrypt_ecb(MCRYPT_BLOWFISH, ENCRYPTION_KEY, $enc_str, MCRYPT_DECRYPT);
$xml = simplexml_load_string($xml_str);
if(!is_object($xml))
respond(INVALID_REQUEST);
// Determine requested function and invoke handler
switch($xml->function[0])
{
case FUNCTION_1:
foobar1($xml);
break;
case FUNCTION_2:
foobar2($xml);
break;
default:
respond(INVALID_REQUEST);
}
?>
Basically (for those not familiar with PHP) it means I can call this url (i.e. php script) with some arguments from my C++ code (POST method), which then invokes the appropriate function on the server side.
Can I do this using the ASP.Net framework ?. I mean if I have a 'page' called 'functions.aspx' (for example), could I pass it parameters via POST (say) and invoke methods in say a "code-behind" C# library ?
I can't actually think of a reason why this cannot be, but I thought I'd better ask in here first.
A small sample class or C# code (like the PHP code above) showing how I may do this would be much appreciated
Yes, you can.
$_POST is equivalent to Request.Form.
base64_decode is equivalent to Convert.FromBase64String
I don't know what decryption to use to match that, but they are in the System.Security.Cryptography namespace.
You can use an XmlDocument object to handle the XML data.
Normally an ASP.NET page use the markup in the aspx file to render the page, but you can remove everything in the page (except the @page tag) and output anything you like from the code behind using Response.Write.
--
Göran Andersson
_____
http://www.guffa.com
.
- References:
- How may I implement this functionality using ASP.Net ?
- From: Bit Byte
- How may I implement this functionality using ASP.Net ?
- Prev by Date: Re: For loop
- Next by Date: Re: RegularExpressionValidator Validation Expression
- Previous by thread: How may I implement this functionality using ASP.Net ?
- Next by thread: Combo/Dropdown box among other field
- Index(es):
Relevant Pages
|