How may I implement this functionality using ASP.Net ?

B

Bit Byte

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Bit said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top