【问题标题】:what is the equivalent code for php in c# [closed]c#中php的等效代码是什么[关闭]
【发布时间】:2012-07-02 14:34:45
【问题描述】:

我正在.net 中进行跨域发布,但在net 中,他们为我提供了php 示例....我想将php 代码转换为.net。请帮忙。

 <?php
        header('Content-type: text/html');
        header('Access-Control-Allow-Origin: *');
        $uri = 'http'. ($_SERVER['HTTPS'] ? 's' : null) .'://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        echo('<p>This information has come from <a href="' . $uri . '">' . $uri . '</a></p>');
    ?>

【问题讨论】:

    标签: c# php asp.net xmlhttprequest cross-domain


    【解决方案1】:

    试试这样的:-

    System.Net.WebRequest request = base.GetWebRequest(uri);         
    request.Headers.Add("Content-type", "text/html");
    request.Headers.Add("Access-Control-Allow-Origin", "*");
    

    $_SERVER 等价于Request.ServerVariables[]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-20
      • 2014-02-20
      • 1970-01-01
      • 2015-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多