Sending data to other web-app

Discussion in 'ASP .Net' started by Christina N, Sep 13, 2004.

  1. Christina N

    Christina N Guest

    What is the easiest way to make an ASP.Net application send data to another
    web-app? For instance I would like APP3 to log user stats from APP1 and
    APP2. The applications are located on different IIS servers.

    Put in another way, can I send a datastring to another web-app without
    having the IE client expecting a post back from that server?

    Best regards,
    Christina
    Christina N, Sep 13, 2004
    #1
    1. Advertising

  2. Christina N

    Shiva Guest

    One option is to use HttpWebRequest to manually post the data to the logging
    app.

    "Christina N" <> wrote in message
    news:...
    What is the easiest way to make an ASP.Net application send data to another
    web-app? For instance I would like APP3 to log user stats from APP1 and
    APP2. The applications are located on different IIS servers.

    Put in another way, can I send a datastring to another web-app without
    having the IE client expecting a post back from that server?

    Best regards,
    Christina
    Shiva, Sep 13, 2004
    #2
    1. Advertising

  3. Christina N

    Christina N Guest

    Okay, but HOW do I do that? Can you help me?

    Christina



    "Shiva" <> wrote in message
    news:O%...
    > One option is to use HttpWebRequest to manually post the data to the

    logging
    > app.
    >
    > "Christina N" <> wrote in message
    > news:...
    > What is the easiest way to make an ASP.Net application send data to

    another
    > web-app? For instance I would like APP3 to log user stats from APP1 and
    > APP2. The applications are located on different IIS servers.
    >
    > Put in another way, can I send a datastring to another web-app without
    > having the IE client expecting a post back from that server?
    >
    > Best regards,
    > Christina
    >
    >
    >
    Christina N, Sep 13, 2004
    #3
  4. Christina N

    Shiva Guest

    Hi,
    Check these for a sample:
    http://www.netomatix.com/HttpPostData.aspx
    http://www.codeproject.com/csharp/HttpWebRequest_Response.asp

    HTH.

    "Christina N" <> wrote in message
    news:...
    Okay, but HOW do I do that? Can you help me?

    Christina



    "Shiva" <> wrote in message
    news:O%...
    > One option is to use HttpWebRequest to manually post the data to the

    logging
    > app.
    >
    > "Christina N" <> wrote in message
    > news:...
    > What is the easiest way to make an ASP.Net application send data to

    another
    > web-app? For instance I would like APP3 to log user stats from APP1 and
    > APP2. The applications are located on different IIS servers.
    >
    > Put in another way, can I send a datastring to another web-app without
    > having the IE client expecting a post back from that server?
    >
    > Best regards,
    > Christina
    >
    >
    >
    Shiva, Sep 13, 2004
    #4
  5. Christina,

    Here is a code snippet that shows how to use HttpWebRequest to call
    your App3.

    // From APP1 or APP2
    -----------------------------------------------------------------------------------------------------
    string strData = "data=call-from-app2";

    HttpWebRequest httpWebRequest=httpWebRequest =
    (HttpWebRequest)WebRequest.Create("App3URL");
    // call with a POST
    httpWebRequest.Method = "POST";

    // POST name-value pairs
    String contentType = "application/x-www-form-urlencoded";
    httpWebRequest.ContentType = contentType;
    // write to the request stream
    byte[] data = new ASCIIEncoding().GetBytes(strData);
    Stream reqStream = httpWebRequest.GetRequestStream();
    reqStream.Write(data,0,data.Length);
    reqStream.Close();
    // execute the request synchronously
    HttpWebResponse httpWebResponse =
    (HttpWebResponse)httpWebRequest.GetResponse();
    -----------------------------------------------------------------------------------------------------

    The above will take care of you passing data to App3. Now, will you be
    writing App 3 too, or does that
    code already exist? If you will write App 3 yourself, then, you can
    get to the request input stream and
    process the input data that your wrote to the stream above. You can do
    the following:


    Stream inputStream = new StreamReader(Request.InputStream);

    // You can get to the header, params, etcs of the request by doing the
    following:

    // ---------------HTTP HEADERS-----------------
    int i=0;
    for(i=0; i<Request.Headers.Keys.Count; i++)
    {
    Console.WriteLine(Request.Headers.Keys+"="+Request.Headers[Request.Headers.Keys]);
    }
    // ---------------HTTP PARAMS-----------------
    for(i=0; i<Request.Params.Keys.Count; i++)
    {
    Console.WriteLine(Request.Params.Keys+"="+Request.Params[Request.Params.Keys]);
    }
    ---------------SERVER VARIABLES------------
    for(i=0; i<Request.ServerVariables.Keys.Count; i++)
    {
    Console.WriteLine(Request.ServerVariables.Keys+"="+Request.ServerVariables[Request.ServerVariables.Keys]);
    }

    One final note about what you are doing. If you are logging request
    info for every request, then I recommend that
    you write an HttpModule to encapsulate that from the rest of the
    application. Writing HttpModules to handle
    this is the way to go. Give me some more information on what you want
    to do and I will help you along a bit more.


    sayed


    "Christina N" <> wrote in message news:<>...
    > What is the easiest way to make an ASP.Net application send data to another
    > web-app? For instance I would like APP3 to log user stats from APP1 and
    > APP2. The applications are located on different IIS servers.
    >
    > Put in another way, can I send a datastring to another web-app without
    > having the IE client expecting a post back from that server?
    >
    > Best regards,
    > Christina
    Sayed Hashimi, Sep 13, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Diehl
    Replies:
    4
    Views:
    797
    Dave Diehl
    Aug 11, 2004
  2. David Hearn
    Replies:
    0
    Views:
    353
    David Hearn
    Apr 18, 2005
  3. =?Utf-8?B?15nXldeg15kg15LXldec15PXkdeo15I=?=

    Sending large files from one app to other

    =?Utf-8?B?15nXldeg15kg15LXldec15PXkdeo15I=?=, Dec 3, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    302
    Michael Nemtsev
    Dec 3, 2006
  4. Jurjen de Groot

    Re-Use Web.UI.UserContol in other web-app

    Jurjen de Groot, Jul 31, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    116
    Arjen
    Jul 31, 2005
  5. Headless Rider

    Control asp.net app from other asp.net app

    Headless Rider, Aug 18, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    98
    Headless Rider
    Aug 18, 2003
Loading...

Share This Page