opsoftware
opsoftware

Reputation: 3

PHP to ASP.Net conversion

I am converting an old PHP porject over to ASP.Net (vb) and wondered if someone could point me in the right direction in order to convert this final snippet of code.

There are 3 functions that are called from within this and i ahve converted those already and to be honest is the session arrays that are giving me the headache.

I have thought about using Hashtables and DirecCasting but this was just confusing me further.

Any help would be greatly apreciated.

$response = array();

$messages = array();

if (!empty($_POST['cbox'])) {

    if (!empty($_SESSION['opsd_user_'.$_POST['cbox']])) {
        $messages = $_SESSION['opsd_user_'.$_POST['cbox']];
    }
} else 
{

    if (!empty($_POST['blist']) && $_POST['blist'] == 1) { getBList(); }

    if (!empty($_POST['initialize']) && $_POST['initialize'] == 1) { 
        getStatus(); 

        if (!empty($_SESSION['opsd_sessionvars'])) {
            $response['initialize'] = $_SESSION['opsd_sessionvars'];

            if (!empty($_SESSION['opsd_sessionvars']['openCBID']) && !empty($_SESSION['opsd_user_'.$_SESSION['opsd_sessionvars']['openCBID']])) {
            $messages = array_merge($messages,$_SESSION['opsd_user_'.$_SESSION['opsd_sessionvars']['openCBID']]);
            }
        }
    } else {

        if (empty($_SESSION['opsd_sessionvars'])) {
            $_SESSION['opsd_sessionvars'] = array();
        }

        if (!empty($_POST['sessionvars'])) {
            ksort($_POST['sessionvars']);
        } else {
            $_POST['sessionvars'] = '';
        }

        if (!empty($_POST['updatesession']) && $_POST['updatesession'] == 1) { 
            $_SESSION['opsd_sessionvars'] = $_POST['sessionvars'];
        }

        if ($_SESSION['opsd_sessionvars'] != $_POST['sessionvars']) {
            $response['updatesession'] = $_SESSION['opsd_sessionvars'];
        }

    }

    getLastTimestamp();
    fetchMessages();
}

Upvotes: 0

Views: 672

Answers (1)

Harper Shelby
Harper Shelby

Reputation: 16585

I think what you're looking for is the Session and Request.Form properties of the ASP.NET page. A simple find/replace of $_SESSION with Session in the page should work wonders, as should a replacement of $_POST with Request.Form.

Upvotes: 1

Related Questions