简体   繁体   English

将值从ASP.NET传递到PHP

[英]Passing values from ASP.NET to PHP

Is there anyway to pass values from ASP.NET to PHP easily using Session or any other? 无论如何,是否可以使用Session或其他任何方法将值从ASP.NET轻松传递给PHP? 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. 任何人要么更正下面的代码,要么向我建议一种不使用URL查询字符串就将值从ASP.NET传递到PHP的方法。

ASP.NET code. ASP.NET代码。

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代码。

<?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. 使用httpwebrequest将来自asp.net的数据发布到php页面,服务器端全部完成。
  2. A cookie with an encrypted value. 具有加密值的cookie。
  3. If php and .net are both run on the same server, save to file system. 如果php和.net都在同一服务器上运行,请保存到文件系统。
  4. A database server. 数据库服务器。
  5. ASP.NET supports multiple forms of persisting session state. ASP.NET支持多种形式的持久会话状态。 State Server and Sql being 2 of them. 状态服务器和Sql是其中的2个。 I'm sure php could be configured to read them. 我确定php可以配置为读取它们。 You'd have to research how to do that. 您必须研究如何做到这一点。 An article for sharing session between ASP.NET and classic ASP. 有关在ASP.NET和经典ASP之间共享会话的文章。 Conceptually the same, and has the ASP.NET configuration part in the article. 概念上是相同的,并且在本文中具有ASP.NET配置部分。 http://msdn.microsoft.com/en-us/library/aa479313.aspx 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. 创建一个存储来自asp.net的数据的Web服务,然后php在需要时检索它。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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