Post Data using Httpwebrequest in Asp.net

90 views
Skip to first unread message

Jeena Ajiesh

unread,
Jul 4, 2012, 3:22:23 AM7/4/12
to dotnetde...@googlegroups.com

Friends,

I want to post the data to another url and i have the code like:

Dim uri As New Uri("http://www.xxx.asp")

        Dim data As String = ""

        If (uri.Scheme = uri.UriSchemeHttp) Then

            data = "Msg=" & Message & "&Source=" & Source & "&Msgtype=Type1"

 

            Dim request As HttpWebRequest = HttpWebRequest.Create(uri)

            request.Method = WebRequestMethods.Http.Post

            request.ContentLength = data.Length

            request.ContentType = "application/x-www-form-urlencoded"

 

            Dim writer As New StreamWriter(request.GetRequestStream())

            writer.Write(data)

            writer.Close()

 

            Dim response As HttpWebResponse = request.GetResponse()

            Dim reader As New StreamReader(response.GetResponseStream())

            Dim tmp As String = reader.ReadToEnd()

            response.Close()

        End If

I have a message like “Welcome back”, this message cannot be fixed in program, it will change accordingly.

Everything is working fine except , it displays message like “Welcomeback”.Space is missing.

Does anyone know why it is so?

 

Thanks & Regards

Jeena Ajiesh

 

Jeena Ajiesh

unread,
Jul 10, 2012, 5:40:59 AM7/10/12
to dotnetde...@googlegroups.com

Thanks for the reply,

But this message is directly entered from Client side, so is there any chance to detect the space & add this ‘&#20’ in between?

 

Thanks & Regards

Jeena Ajiesh

 

From: dotnetde...@googlegroups.com [mailto:dotnetde...@googlegroups.com] On Behalf Of Barry Etheridge
Sent: Thursday, July 05, 2012 5:15 PM
To: dotnetde...@googlegroups.com
Subject: [DotNetDevelopment] Re: Post Data using Httpwebrequest in Asp.net

 

HTTP responses will ignore spaces. Try Welcome &#20Back

--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to dotnetde...@googlegroups.com
To unsubscribe from this group, send email to
dotnetdevelopm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Jeena Ajiesh

unread,
Jul 12, 2012, 2:26:02 AM7/12/12
to dotnetde...@googlegroups.com

Thank you for the reply, let me try out this & let u know.

 

Thanks & Regards

Jeena Ajiesh

 

From: dotnetde...@googlegroups.com [mailto:dotnetde...@googlegroups.com] On Behalf Of Barry Etheridge
Sent: Wednesday, July 11, 2012 6:31 PM
To: dotnetde...@googlegroups.com
Subject: Re: [DotNetDevelopment] Re: Post Data using Httpwebrequest in Asp.net

 

I'm assuming that Message is a String so at whatever point Message is set ... add ..

 

If Message.Contains(" ") Then Message = Message.Replace(" ", " &&#20")

 

Yes it is a double ampersand; needed to register as a literal.

Reply all
Reply to author
Forward
0 new messages