2
2b|!2b==?
I want to create a really simple (proof of concept) website with the
following requirements.
1). I can specify the web address (say http://localhost/mywebsite)
2). I have a "handler" script (in C#) that allows me to respond to
requests from a client (see notes below):
Notes:
=======
I have an existing application which consists of a C++ frontend, and a
PHP backend. I am moving from PHP to ASP.Net at the server side. At the
server side, I have PHP 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.
I Know the following (thanks to Göran Andersson )
==================================================
1). $_POST is equivalent to Request.Form.
2). base64_decode is equivalent to Convert.FromBase64String
3). Equivalent decryption may be found in System.Security.Cryptography
namespace.
4). I can use an XmlDocument object to handle the XML data.
5). Normally an ASP.NET page uses the markup in the aspx file to render
the page, but I can remove everything in the page (except the @page tag)
and output anything I like from the code behind using Response.Write.
Given the above points, could someone please post a C# equivalent of the
PHP snippet above (you may leave out the encryption - if you don't know
thw equivalent function in C#) - I just need the boilerplate C# code to
get started, so that I can implement this server side "handler" in the
website I described.
following requirements.
1). I can specify the web address (say http://localhost/mywebsite)
2). I have a "handler" script (in C#) that allows me to respond to
requests from a client (see notes below):
Notes:
=======
I have an existing application which consists of a C++ frontend, and a
PHP backend. I am moving from PHP to ASP.Net at the server side. At the
server side, I have PHP 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.
I Know the following (thanks to Göran Andersson )
==================================================
1). $_POST is equivalent to Request.Form.
2). base64_decode is equivalent to Convert.FromBase64String
3). Equivalent decryption may be found in System.Security.Cryptography
namespace.
4). I can use an XmlDocument object to handle the XML data.
5). Normally an ASP.NET page uses the markup in the aspx file to render
the page, but I can remove everything in the page (except the @page tag)
and output anything I like from the code behind using Response.Write.
Given the above points, could someone please post a C# equivalent of the
PHP snippet above (you may leave out the encryption - if you don't know
thw equivalent function in C#) - I just need the boilerplate C# code to
get started, so that I can implement this server side "handler" in the
website I described.