ASP.Net newbie question (example code appreciated)

Discussion in 'ASP .Net' started by 2b|!2b==?, Mar 29, 2007.

  1. 2b|!2b==?

    2b|!2b==? Guest

    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):

    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,

    $xml = simplexml_load_string($xml_str);


    // Determine requested function and invoke handler
    case FUNCTION_1:

    case FUNCTION_2:


    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
    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.
    2b|!2b==?, Mar 29, 2007
    1. Advertisements

  2. I think, something like this

    protected void Page_Init(object sender, EventArgs e)

    string enc_str =
    string xml_str = enc_str; // mcrypt_ecb???

    XmlDocument d = new XmlDocument();

    if (d == null)

    // depends on structure of your xml, e.g.
    first = d.DocumentElement.FirstChild;

    switch (d)
    case "1":
    case "2":
    .... // error
    Alexey Smirnov, Apr 2, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.