简体   繁体   中英

Passing values from ASP.NET to PHP

Is there anyway to pass values from ASP.NET to PHP easily using Session or any other? I tried in the below way but it didn't work for me. Anybody either correct the below code or suggest me a way to pass values from ASP.NET to PHP without using URL query string.

ASP.NET code.

protected void Button1_Click(object sender, EventArgs e)
    {
        HttpCookie cookie = new HttpCookie("myvalue1");
        cookie.Value = "joe@example.com";
        Response.Redirect("Default.php");
    }

PHP code.

<?php
session_start();
$_COOKIE['myvalue1'];
$cookies = getCookies();
$sessionId = $cookies['myvalue1'];
?>

您可以在PHP端创建WSDL / REST API,只需将数据从.Net发送到此API

There are a few ways to do this, but none are particularly sexy.

  1. Post the data from asp.net using an httpwebrequest to a php page, all done server side.
  2. A cookie with an encrypted value.
  3. If php and .net are both run on the same server, save to file system.
  4. A database server.
  5. ASP.NET supports multiple forms of persisting session state. State Server and Sql being 2 of them. I'm sure php could be configured to read them. You'd have to research how to do that. An article for sharing session between ASP.NET and classic ASP. Conceptually the same, and has the ASP.NET configuration part in the article. http://msdn.microsoft.com/en-us/library/aa479313.aspx

EDIT: You could even roll your own state server. Create a webservice that stores data from asp.net and php retrieves it when needed.

Response.Redirect("Default.php?myparam=myvalue");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM