Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通过WebAPI将信息发送到数据库?_C#_Api_Asp.net Web Api_Webrequest - Fatal编程技术网

C# 通过WebAPI将信息发送到数据库?

C# 通过WebAPI将信息发送到数据库?,c#,api,asp.net-web-api,webrequest,C#,Api,Asp.net Web Api,Webrequest,目前我正在使用WebAPI将数据发送到本地服务器 下面是XML 阵列测量 伤亡人数 信标:A1信标 纬度51.41459808纬度 经度-5.43823242经度 所有者姓名Damola OwnerName先生 脉冲200脉冲 伤亡人数 阵列测量 我可以使用WebRequest从另一个“位置”显示此信息 是否可以获取此信息以填充SQL数据库 using System; using System.IO; using System.Net; using System.Text; namespace

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

阵列测量 伤亡人数
信标:A1信标
纬度51.41459808纬度
经度-5.43823242经度
所有者姓名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();
    }
}

对于这种情况,我建议使用实体框架