473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How may I implement this functionality using ASP.Net ?

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

Feb 25 '07 #1
1 1203
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
Feb 25 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Jim | last post by:
I am using VB.Net 2.0 and I am completely new to the concept of implementing interfaces. Can anyone explain "implementing interfaces" to me and perhaps give me an example of implementing an...
16
by: Jim | last post by:
I am using VB.Net 2.0 and I am completely new to the concept of implementing interfaces. Can anyone explain "implementing interfaces" to me and perhaps give me an example of implementing an...
14
by: Jim | last post by:
I am using VB.Net 2.0 and I am completely new to the concept of implementing interfaces. Can anyone explain "implementing interfaces" to me and perhaps give me an example of implementing an...
15
by: Jim | last post by:
I am using VB.Net 2.0 and I am completely new to the concept of implementing interfaces. Can anyone explain "implementing interfaces" to me and perhaps give me an example of implementing an...
20
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got the following C++ code. The first routine runs in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.