• 大小: 66KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: C#
  • 标签: c#  http接口  

资源简介

实际项目往往以json或xml格式传输数据,本demo直接传输数据。先用vs运行接口程序,或发布到iis即可;再运行接口调用程序,调用地址以实际为准。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace VipJump
{
    public partial class test : System.Web.UI.Page
    {
        private string urlnode = ConfigurationSettings.AppSettings[“urlnode“];
        protected void Page_Load(object sender EventArgs e)
        {
            if(string .IsNullOrEmpty (urlnode))
            {
                urlnode =“jump“;
            }
            try
            {
                string res = GetPost();
                Response.Write(res);
            }
            catch (Exception ex)
            {
                Response.Write(“异常:“+ex.Message);
            }
        }

        public string GetStringURLPara()
        {
            if (Request.QueryString[urlnode] != null)
            {
                string method = Request.QueryString[urlnode].ToString();
                return method;
            }
            return ““;
        }

        public string GetPost()
        {
            if (“POST“ == Request.RequestType)
            {
                System.IO.Stream sm = Request.InputStream;//获取post正文
                int len = (int)sm.Length;//post数据长度
                byte[] inputByts = new byte[len];//字节数据用于存储post数据
                sm.Read(inputByts 0 len);//将post数据写入byte数组中
                sm.Close();//关闭IO流
                
                //**********下面是把字节数组类型转换成字符串**********
                
                string data = Encoding.GetEncoding(“UTF-8“).GetString(inputByts);//转为unicode编码
                //data = Server.UrlDecode(data);//url参数用到.
                return data;
            }
            else
                return null;


        }


     

    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-12-03 20:23  基于http的接口\
     目录           0  2015-12-03 20:23  基于http的接口\http接口程序demo\
     目录           0  2015-12-03 20:23  基于http的接口\http接口程序demo\VipJump\
     文件       28160  2015-12-03 11:03  基于http的接口\http接口程序demo\VipJump\VipJump.v11.suo
     文件         913  2015-12-03 11:03  基于http的接口\http接口程序demo\VipJump\demo.sln
     文件       27648  2015-12-03 11:11  基于http的接口\http接口程序demo\VipJump\demo.v11.suo
     目录           0  2015-12-03 20:23  基于http的接口\http接口程序demo\VipJump\vipjump\
     目录           0  2015-12-03 20:34  基于http的接口\http接口程序demo\VipJump\vipjump\App_Data\
     目录           0  2015-12-03 20:23  基于http的接口\http接口程序demo\VipJump\vipjump\Properties\
     文件        1334  2015-12-02 15:32  基于http的接口\http接口程序demo\VipJump\vipjump\Properties\AssemblyInfo.cs
     文件        1245  2015-12-02 15:32  基于http的接口\http接口程序demo\VipJump\vipjump\Web.Debug.config
     文件        1306  2015-12-02 15:32  基于http的接口\http接口程序demo\VipJump\vipjump\Web.Release.config
     文件         991  2015-12-03 09:24  基于http的接口\http接口程序demo\VipJump\vipjump\Web.config
     目录           0  2015-12-03 20:23  基于http的接口\http接口程序demo\VipJump\vipjump\bin\
     文件        5632  2015-12-03 11:10  基于http的接口\http接口程序demo\VipJump\vipjump\bin\VipJump.dll
     文件       17920  2015-12-03 11:10  基于http的接口\http接口程序demo\VipJump\vipjump\bin\VipJump.pdb
     文件        4718  2015-12-03 11:03  基于http的接口\http接口程序demo\VipJump\vipjump\httpdemo.csproj
     文件        1084  2015-12-03 11:03  基于http的接口\http接口程序demo\VipJump\vipjump\httpdemo.csproj.user
     目录           0  2015-12-03 20:23  基于http的接口\http接口程序demo\VipJump\vipjump\obj\
     目录           0  2015-12-03 20:23  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\
     文件        6659  2015-12-03 11:04  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2015-12-03 20:34  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\TempPE\
     文件         456  2015-12-02 15:33  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\VipJump.csproj.FileListAbsolute.txt
     文件        1572  2015-12-02 15:33  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\VipJump.csprojResolveAssemblyReference.cache
     文件        5632  2015-12-03 11:10  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\VipJump.dll
     文件       17920  2015-12-03 11:10  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\VipJump.pdb
     文件         602  2015-12-03 11:03  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\httpdemo.csproj.FileListAbsolute.txt
     文件        1572  2015-12-03 11:03  基于http的接口\http接口程序demo\VipJump\vipjump\obj\Debug\httpdemo.csprojResolveAssemblyReference.cache
     文件         105  2015-12-02 15:42  基于http的接口\http接口程序demo\VipJump\vipjump\test.aspx
     文件        1984  2015-12-03 11:10  基于http的接口\http接口程序demo\VipJump\vipjump\test.aspx.cs
     文件         460  2015-12-02 15:34  基于http的接口\http接口程序demo\VipJump\vipjump\test.aspx.designer.cs
............此处省略24个文件信息

评论

共有 条评论