以编程方式创建asp.net请求并处理响应 [英] Programmatically creating asp.net request and handling response

查看:74
本文介绍了以编程方式创建asp.net请求并处理响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

请让我知道如何获得从URL生成的部分响应.

我已编写此代码:

Hello everyone,

Please let me know how to get part of response generated from the url.

I have written this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
 
namespace Experiment
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string url = "https://api.smscountry.com/smscwebservices_bulk_reports.aspx?
user=xxxx&passwd=xxxx&fromdate=DD/MM/YYYY 00:00:00 &todate=DD/MM/YYYY
23:59:59";
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            httpWebRequest.Method = "POST";
            httpWebRequest.ContentType = "application/x-www-form-urlencoded";
 
            HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            Stream responseStream = httpWebResponse.GetResponseStream();
            StreamReader streamReader = new StreamReader(responseStream);
            string response = streamReader.ReadToEnd();
 
            Response.Write(Response);
        }
    }
}



我不确定此代码是否有效.
我所做的只是简单地将URL粘贴到浏览器中所需的参数,现在,通过在浏览器中用日期戳,用户名和密码简单地编写url的方式将该URL生成输出,即:



I am not sure whether this code will work or not.
What I have done is simply pasted the URL with the parameters it wants in the browser and now the output is generated by this url on simple writing the url in the browser with date stamp, userid and password is:

165276683~919870657048~2~02/04/2011 17:31:00~0.04~~4/2/2011 5:30:50 PM#165277227~919870657048~2~02/04/2011 17:34:00~0.04~~4/2/2011 5:33:47 PM#165281555~919870657048~2~02/04/2011 17:59:00~0.04~~4/2/2011 5:59:09 PM#165287028~919870657048~2~02/04/2011 18:37:00~0.04~~4/2/2011 6:36:38 PM#165449882~919146771088~9~03/04/2011 15:03:00~0.04~~4/3/2011 3:03:13 PM#165461364~919146771088~9~03/04/2011 16:09:00~0.08~~4/3/2011 4:09:46 PM#165461364~919714033112~9~03/04/2011 16:10:00~0.08~~4/3/2011 4:10:30 



输出的格式为Response:-jobid〜mobilenumber〜messagestatus〜donestamp〜message_text〜receivestamp

现在,我只需要手机号码,从此就可以了,该怎么办?

请,请帮助我,如何只获取URL生成的部分响应

谢谢&问候,
Krunal Panchal



The format of the output is Response: - jobid~mobilenumber~messagestatus~donestamp~message_text~receivestamp

Now I need only the Mobile number, donestamp from this, how could I do this?

Please , please help me, how to get only part of the response generated by the URL

Thanks & Regards,
Krunal Panchal

推荐答案

我想您可以在这里找到您的解决方案:
http://msdn.microsoft.com/en-us/library/ms150046.aspx [ ^ ]
I think you can find your solution here:
http://msdn.microsoft.com/en-us/library/ms150046.aspx[^]


这篇关于以编程方式创建asp.net请求并处理响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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