【问题标题】:Sending information through WebAPI to a database?通过 WebAPI 将信息发送到数据库?
【发布时间】:2014-02-14 19:50:01
【问题描述】:

目前我正在使用 WebAPI 将数据发送到本地服务器 XML 在下面

ArrayOfCasualty 伤亡
BeaconID:A1 BeaconID
纬度 51.41459808 纬度
经度 -5.43823242 经度
OwnerName Damola 先生 OwnerName
脉冲 200 脉冲
伤亡
人员伤亡数组

我可以使用 WebRequest 从另一个“位置”显示此信息 是否可以获取此信息来填充 SQL 数据库?

using System;
using System.IO;
using System.Net;
using System.Text;

namespace WebApplication5
{
public class WebRequestGetExample
{
    public static void Main()
    {

        WebRequest request = WebRequest.Create(
          "http://localhost:5150/api/casualty");
        WebResponse response = request.GetResponse();

        Console.WriteLine(((HttpWebResponse)response).StatusDescription);

        Stream dataStream = response.GetResponseStream();

        StreamReader reader = new StreamReader(dataStream);

        string responseFromServer = reader.ReadToEnd();

        Console.WriteLine(responseFromServer);

        response.Close();
    }
}

【问题讨论】:

    标签: c# api asp.net-web-api webrequest


    【解决方案1】:
    猜你喜欢
    • 2017-01-01
    • 2016-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多