Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

problem with url on http post

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CindyH - 19 May 2008 16:18 GMT
Hi:

I have the following code:

         Dim url As String = "http://xx01xx01:800/some.ashx"
         Dim myrequest As System.Net.WebRequest = Nothing
         Dim myresponse As System.Net.WebResponse = Nothing
             'Prepare web request
             myrequest = System.Net.WebRequest.Create(url)
             'use POST
             myrequest.Method = "POST"
             'Set the content type
             Request.ContentType = "application/x-www-form-urlencoded"
             Dim byteArray As Byte() =
System.Text.Encoding.UTF8.GetBytes(dataToPost)
             'Get length of content
             myrequest.ContentLength = byteArray.Length
             'Get request stream
             Dim newStream As System.IO.Stream = myrequest.GetRequestStream
             'Send the data.
             newStream.Write(byteArray, 0, byteArray.Length)
             ' Close stream
             newStream.Close()
             'Send the Post request and wait for the response.
             myresponse = myrequest.GetResponse()

If I use for the first line something like this:
Dim url As String = "http://www.someplace.com/somepage.aspx" then
everything works fine, but now I need to use the real address which is
something like this: "http://xx01xx01:800/some.ashx"
When the code hits the line:
Dim newStream As System.IO.Stream = myrequest.GetRequestStream - I'm
getting the following error:
system.net.webexception: The remote name could not be resolved: 'xx01xx01'
Does anyone have any ideas why I'm having problems with the stream for a url
address like this?
Thanks,
Cindy
bruce barker - 19 May 2008 16:38 GMT
the error means the dns lookup on the requested server name did not return an
ipaddress. check which dns server you web server uses.

-- bruce (sqlwork.com)

> Hi:
>
[quoted text clipped - 34 lines]
> Thanks,
> Cindy
CindyH - 19 May 2008 16:41 GMT
The guy gave me the wrong url address.
Now I'm able to send the post, but response is empty and getting this error:
system.net.webexception: The remote server returned an error: (500) Internal
Server Error.
Would this be my problem or his?
Thanks,
Cindy

> Hi:
>
[quoted text clipped - 35 lines]
> Thanks,
> Cindy
Patrice - 19 May 2008 17:19 GMT
Not really possible to know. Either you provided incorrect data, either
there is something wrong server side for the valid data you provided....

You can't do much more than double checking you provided good data (possibly
a sample case provided by this guy and that works would be fine for testing)
before getting in touch with the third party...

As a side note, you may want to check WebClient that will encode form data
for you (you just have to provide pairs of values). For some reason it looks
like I often see code that prefer to use the lowest level API even when not
really needed (to avoid having to swtich if you alter really need it ?)...

Also a classic problem is not providing a user agent string or any other
http header that is used by the server side page...

--
Patrice

"CindyH" <chenschel@new.rr.com> a écrit dans le message de groupe de
discussion : #4SdSbcuIHA.420@TK2MSFTNGP02.phx.gbl...
> The guy gave me the wrong url address.
> Now I'm able to send the post, but response is empty and getting this
[quoted text clipped - 45 lines]
>> Thanks,
>> Cindy
CindyH - 19 May 2008 18:31 GMT
Ok, thanks.

> Not really possible to know. Either you provided incorrect data, either
> there is something wrong server side for the valid data you provided....
[quoted text clipped - 66 lines]
>>> Thanks,
>>> Cindy

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.