从ASP.NET传递值到PHP [英] Passing values from ASP.NET to PHP

查看:111
本文介绍了从ASP.NET传递值到PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正是有轻松使用Session或任何其他从ASP.NET值传递给PHP?我想在下面的方式,但它并没有为我工作。任何人或者更正低于code或建议我的方式来从ASP.NET值传递给PHP不使用URL查询字符串。

ASP.NET code。

 保护无效的button1_Click(对象发件人,EventArgs的发送)
    {
        的HttpCookie饼干=新的HttpCookie(myvalue1);
        cookie.Value =joe@example.com;
        的Response.Redirect(如default.php);
    }

PHP code。

 < PHP
在session_start();
$ _COOKIE ['myvalue1'];
$饼干=的getCookies();
$的sessionId = $饼干['myvalue1'];
?>


解决方案

有几个方法可以做到这一点,但没有特别性感。


  1. 从asp.net使用HttpWebRequest的一个PHP页面发布数据,全部完成服务器端。

  2. 与加密值的cookie。

  3. 如果PHP和.NET都在同一台服务器上运行两个,保存到文件系统中。

  4. 数据库服务器。

  5. ASP.NET支持持续会话状态的多种形式。国家Server和SQL是其中的2。我敢肯定,PHP可以被配置为阅读。你必须研究如何做到这一点。对于ASP.NET与传统的ASP之间共享会话的文章。从概念上是相同的,有文章中的ASP.NET配置部分。 http://msdn.microsoft.com/en-us/library/aa479313.aspx

编辑:
你甚至可以推出自己的状态服务器。创建一个从asp.net存储数据并在需要时PHP获取它的web服务。

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'];
?>

解决方案

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.

这篇关于从ASP.NET传递值到PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆