Urgent - Transform PHP-Session-Code to ASP.NET (Framework Version 4) RRS feed

  • Question

  • User-146845122 posted


    for an urgent project, I have to put in a code snippet which works well in PHP in a ASPX-based website. I never developed in ASP.NET so I'm quite overwhelmed by this although it's no rocket science, I know :)

    If someone would be so kind, to translate (or help me to translate) the php code snippet to *inline* ASP-Code what I can put before an iFrame in a normal HTML file.

    Here's the php snippet:

        if (!isset($_SESSION['isIFrameSessionStarted']))
            $_SESSION['isIFrameSessionStarted'] = 1;
            $redirect = rawurlencode('http://' . "{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
            header('Location: http://domain.com/start-session.php?redirect=' . $redirect);

    Any help is highly appreciated!

    Bye Defcon0

    Friday, February 6, 2015 4:33 AM


  • User465171450 posted

    You can give this a try. I usually don't work inline so this still may need adjustment.

    <script  runat="server">
    protected override OnLoad(object sender, EventArgs e)
        if(Session["isIFrameSessionStarted'] == null)
             Session["isIFrameSessionStarted"] = 1;
             string redirect = "http://" + Request.ServerVariables["HTTP_HOST"].ToString() + Request.ServerVariables["REQUEST_URI"].ToString();
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 6, 2015 7:56 AM