开发者

without page load how to get response using asp.net

I need a coding to get response from my deskto开发者_StackOverflow中文版p application to my web page using asp.net

I send a request from my recharge.aspx page to desktop application.

http://122.172.208.202/MARSrequest/?operator=RA&number=9900122334&amount=100&reqref=A0000001

so my desktop application get the request and perform the task and send the response to other page that is responseparser.aspx

the response like

http://www.abc.com/responseparser.aspx?ref=10293&number=9894380156&amount=100&status=SUCCESS&transid=547965399 &simbal=1000

so how to get response with out loading the responseparser page it is possible or any other idea to get the response.

my doubt is without loading a page can able to perform some operation like insert a record or create text file using asp.net


You appear to have asked this question several times in several different ways. This is not an acceptable way of using StackOverflow. If your original question is not getting the answer(s) your looking for, please consider editing and revising your question. Please consider commenting on your questions and taking the advice of other commenters.

To answer your question. I think you're looking to execute some sort of Web Service instead of loading a page. Does this sound right?

If so, I'd suggest either using one of the following

  • a generic HttpHandler (more info in this forum post)
  • a WCF application that can manage your service layer.
  • an MVC Application that manages the requests (this is my personal favorite - I build these completely without Views and simply return JSON for all of my {success: true/false}.)

In short, the quickest way I can think of to do this would be to use the FIRST option (HttpHandler) and change your request to the following

http://localhost/responsepage.ashx?number=9894380156&amount=10&status=success

Notice the ashx extension on the response page. It's no longer a web page but a web handler... you'll want to do some research in order to get a handle on it.


Not sure if this if this works same for desktop applications but maybe it works with

protected void YourThing()
{

Refresh();

}

protected void Refresh()

{
Response.redirect(Request.Rawurl);
}


not sure but try

for(!Page.IsPostback)
{
do stuf here
}


You can use WebService or HttpHandler.

I would prefer WebService (parser.asmx):

namespace Test.Service
{
  [WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [ToolboxItem(false)]
  public class WebService1 : WebService
  {
    [WebMethod]
    public void Parse(string @ref, long number, double amount, string status, int transid, int simbal)
    {
      // some code
    }
  }
}

POST-request example:

POST /{path}/Parser.asmx/Parse HTTP/1.1
Host: ***
Content-Type: application/x-www-form-urlencoded
Content-Length: ***

ref=string&number=string&amount=string&status=string&transid=string&simbal=string


I think you can easily port your ASP code using the SqlClient classes. Most suitable variant for you is SqlCommand with ExecuteNonQuery method:

using (SqlConnection connection = new SqlConnection(
           connectionString))
{
    SqlCommand command = new SqlCommand(queryString, connection);
    command.Connection.Open();
    command.ExecuteNonQuery();
}


In that case, I usually put whatever appropriate ADO.NET code into page_load but since you want to do it before page loading, why don't you use "page_init"? For example, put following code into code-behind

protected void Page_Init(object sender, EventArgs e)
{
    //your code is here
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜