473,856 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

webrequest - webresponse again

Hi - hope someone can help with this - this code was working for a while in
the 'real' code and then suddenly stopped - not sure what happen.
I made two simple forms on localhost to try to test what is going on.
I'm not getting any errors right now, but code is not working either - not
reading the post in second form or else the first form is not sending it
correctly.
---------------------------------------------------------------------------------------------------------------------------------------
This is the Post.xml file I'm sending as stream (string), I have also tried
just simple text file with one line and get same result:
It looks like this when it comes out of the streamreader - before sending to
other form

"<?xml version="1.0"?>
<userlist ACTION="newuser " VENDORNAME="som ename">
<amouser AMOAID="101" AMOUSERNAME="Bi lly Jones" AMOAROLES="Stud ent"
AMOAPRODUCTS="p roduct1,product 2" />
</userlist>"

---------------------------------------------------------------------------------------------------------------
This is code - in first form - sends the post to the second form:
This code I've seen on internet in a number of places - all basically the
same.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim fileName As String =
"C:\Inetpub\www root\AnnieGreen Springs\Post.xm l"
Dim uri As String = "http://localhost/AnnieGreenSprin gs/testb.aspx"
Dim req As System.net.WebR equest = Nothing
Dim rsp As System.net.WebR esponse = Nothing
Try
req = System.Net.WebR equest.Create(u ri)
req.Method = "POST"
req.ContentType = "text/xml"
Dim writer As System.IO.Strea mWriter = New
System.IO.Strea mWriter(req.Get RequestStream() )
writer.WriteLin e(GetTextFromXM LFile(fileName) )
writer.Close()
rsp = req.GetResponse
Catch webex As System.Net.WebE xception
Throw webex
Catch Ex As System.Exceptio n
Throw Ex
Finally
If req Is Nothing Then
req.GetRequestS tream().Close()
End If
If rsp Is Nothing Then
rsp.GetResponse Stream().Close( )
End If
End Try
End Sub

Private Function GetTextFromXMLF ile(ByVal file As String) As String
Dim reader As New System.IO.Strea mReader(file)
Dim ret As String = reader.ReadToEn d()
reader.Close()
Return ret
End Function
------------------------------------------------------------------------------------------------------------------
This is code in the second form that should read the post - instead I'm
getting xmldata = "" - so it looks like it's not receiving post.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim xmldata As String
Response.Conten tType = "text/xml"
Response.Clear( )
Dim reader As StreamReader = New
StreamReader(Pa ge.Request.Inpu tStream)
xmldata = reader.ReadToEn d
reader.Close()
End Sub


Jun 27 '08 #1
4 2134
Cindy,

what your caller webresponse object (rsp) says about the request?
Jun 27 '08 #2
Cindy,

I don't think so, moreover, because that you wrote
Hi Martin:

You seem to be the only one that knows anything about this.
I don't want to disapoint you in this, like probably more do.

Moreover, as somebody despite this would have helped you, then he/she
probably had done it in your first message thread, repeating asking the same
question means only that the next question which has the slightest sound to
be the same will be ignored by most regulars here, as is a kind of
convention in newsgroups.

Cor
"CindyH" <ch*******@new. rr.comschreef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Hi - hope someone can help with this - this code was working for a while
in
the 'real' code and then suddenly stopped - not sure what happen.
I made two simple forms on localhost to try to test what is going on.
I'm not getting any errors right now, but code is not working either - not
reading the post in second form or else the first form is not sending it
correctly.
---------------------------------------------------------------------------------------------------------------------------------------
This is the Post.xml file I'm sending as stream (string), I have also
tried
just simple text file with one line and get same result:
It looks like this when it comes out of the streamreader - before sending
to
other form

"<?xml version="1.0"?>
<userlist ACTION="newuser " VENDORNAME="som ename">
<amouser AMOAID="101" AMOUSERNAME="Bi lly Jones" AMOAROLES="Stud ent"
AMOAPRODUCTS="p roduct1,product 2" />
</userlist>"

---------------------------------------------------------------------------------------------------------------
This is code - in first form - sends the post to the second form:
This code I've seen on internet in a number of places - all basically the
same.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim fileName As String =
"C:\Inetpub\www root\AnnieGreen Springs\Post.xm l"
Dim uri As String = "http://localhost/AnnieGreenSprin gs/testb.aspx"
Dim req As System.net.WebR equest = Nothing
Dim rsp As System.net.WebR esponse = Nothing
Try
req = System.Net.WebR equest.Create(u ri)
req.Method = "POST"
req.ContentType = "text/xml"
Dim writer As System.IO.Strea mWriter = New
System.IO.Strea mWriter(req.Get RequestStream() )
writer.WriteLin e(GetTextFromXM LFile(fileName) )
writer.Close()
rsp = req.GetResponse
Catch webex As System.Net.WebE xception
Throw webex
Catch Ex As System.Exceptio n
Throw Ex
Finally
If req Is Nothing Then
req.GetRequestS tream().Close()
End If
If rsp Is Nothing Then
rsp.GetResponse Stream().Close( )
End If
End Try
End Sub

Private Function GetTextFromXMLF ile(ByVal file As String) As String
Dim reader As New System.IO.Strea mReader(file)
Dim ret As String = reader.ReadToEn d()
reader.Close()
Return ret
End Function
------------------------------------------------------------------------------------------------------------------
This is code in the second form that should read the post - instead I'm
getting xmldata = "" - so it looks like it's not receiving post.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim xmldata As String
Response.Conten tType = "text/xml"
Response.Clear( )
Dim reader As StreamReader = New
StreamReader(Pa ge.Request.Inpu tStream)
xmldata = reader.ReadToEn d
reader.Close()
End Sub

Jun 27 '08 #3
Sorry - my mistake - I'm not that familiar with newsgroups and how they
work.

"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:69******** *************** ***********@mic rosoft.com...
Cindy,

I don't think so, moreover, because that you wrote
>Hi Martin:

You seem to be the only one that knows anything about this.

I don't want to disapoint you in this, like probably more do.

Moreover, as somebody despite this would have helped you, then he/she
probably had done it in your first message thread, repeating asking the
same question means only that the next question which has the slightest
sound to be the same will be ignored by most regulars here, as is a kind
of convention in newsgroups.

Cor
"CindyH" <ch*******@new. rr.comschreef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>Hi - hope someone can help with this - this code was working for a while
in
the 'real' code and then suddenly stopped - not sure what happen.
I made two simple forms on localhost to try to test what is going on.
I'm not getting any errors right now, but code is not working either -
not
reading the post in second form or else the first form is not sending it
correctly.
---------------------------------------------------------------------------------------------------------------------------------------
This is the Post.xml file I'm sending as stream (string), I have also
tried
just simple text file with one line and get same result:
It looks like this when it comes out of the streamreader - before sending
to
other form

"<?xml version="1.0"?>
<userlist ACTION="newuser " VENDORNAME="som ename">
<amouser AMOAID="101" AMOUSERNAME="Bi lly Jones" AMOAROLES="Stud ent"
AMOAPRODUCTS=" product1,produc t2" />
</userlist>"

---------------------------------------------------------------------------------------------------------------
This is code - in first form - sends the post to the second form:
This code I've seen on internet in a number of places - all basically the
same.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventAr gs) Handles MyBase.Load
Dim fileName As String =
"C:\Inetpub\ww wroot\AnnieGree nSprings\Post.x ml"
Dim uri As String =
"http://localhost/AnnieGreenSprin gs/testb.aspx"
Dim req As System.net.WebR equest = Nothing
Dim rsp As System.net.WebR esponse = Nothing
Try
req = System.Net.WebR equest.Create(u ri)
req.Method = "POST"
req.ContentType = "text/xml"
Dim writer As System.IO.Strea mWriter = New
System.IO.Stre amWriter(req.Ge tRequestStream( ))
writer.WriteLin e(GetTextFromXM LFile(fileName) )
writer.Close()
rsp = req.GetResponse
Catch webex As System.Net.WebE xception
Throw webex
Catch Ex As System.Exceptio n
Throw Ex
Finally
If req Is Nothing Then
req.GetRequestS tream().Close()
End If
If rsp Is Nothing Then
rsp.GetResponse Stream().Close( )
End If
End Try
End Sub

Private Function GetTextFromXMLF ile(ByVal file As String) As String
Dim reader As New System.IO.Strea mReader(file)
Dim ret As String = reader.ReadToEn d()
reader.Close()
Return ret
End Function
------------------------------------------------------------------------------------------------------------------
This is code in the second form that should read the post - instead I'm
getting xmldata = "" - so it looks like it's not receiving post.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventAr gs) Handles MyBase.Load
Dim xmldata As String
Response.Conten tType = "text/xml"
Response.Clear( )
Dim reader As StreamReader = New
StreamReader(P age.Request.Inp utStream)
xmldata = reader.ReadToEn d
reader.Close()
End Sub


Jun 27 '08 #4
Hi
In the watch - I'm getting the following for rsp when it comes back from 2nd
form:

rsp {System.Net.Htt pWebResponse} System.Net.WebR esponse
- [System.Net.Http WebResponse] {System.Net.Htt pWebResponse}
System.Net.Http WebResponse
CharacterSet "" String
ContentEncoding "" String
ContentLength &H27E Long
ContentType "text/xml; charset=utf-8" String
- Cookies {System.Net.Coo kieCollection} System.Net.Cook ieCollection
Count &H0 Integer
IsReadOnly True Boolean
IsSynchronized False Boolean
Item <cannot view indexed propertySystem. Net.Cookie
+ SyncRoot {System.Net.Coo kieCollection} Object
+ Headers {System.Net.Web HeaderCollectio n} System.Net.WebH eaderCollection
LastModified #4/30/2008 7:28:48 AM# Date
Method "GET" String
+ ProtocolVersion {System.Version } System.Version
+ ResponseUri {System.Uri} System.Uri
Server "Microsoft-IIS/5.1" String
StatusCode OK System.Net.Http StatusCode
StatusDescripti on "OK" String
ContentLength &H27E Long
ContentType "text/xml; charset=utf-8" String
- Headers {System.Net.Web HeaderCollectio n} System.Net.WebH eaderCollection
+ AllKeys {Length=&H7} String()
Count &H7 Integer
Item <cannot view indexed propertyString
+ Keys
{System.Collect ions.Specialize d.NameObjectCol lectionBase.Key sCollection}
System.Collecti ons.Specialized .NameObjectColl ectionBase.Keys Collection
- ResponseUri {System.Uri} System.Uri
AbsolutePath "/AnnieGreenSprin gs/(fospog45n5tclv 55x22co0r1)/testb.aspx"
String
AbsoluteUri
"http://localhost/AnnieGreenSprin gs/(fospog45n5tclv 55x22co0r1)/testb.aspx"
String
Authority "localhost" String
Fragment "" String
Host "localhost" String
HostNameType Dns System.UriHostN ameType
IsDefaultPort True Boolean
IsFile False Boolean
IsLoopback True Boolean
IsUnc False Boolean
LocalPath "/AnnieGreenSprin gs/(fospog45n5tclv 55x22co0r1)/testb.aspx" String
PathAndQuery "/AnnieGreenSprin gs/(fospog45n5tclv 55x22co0r1)/testb.aspx"
String
Port &H50 Integer
Query "" String
Scheme "http" String
SchemeDelimiter "://" String
+ Segments {Length=&H4} String()
UriSchemeFile "file" String
UriSchemeFtp "ftp" String
UriSchemeGopher "gopher" String
UriSchemeHttp "http" String
UriSchemeHttps "https" String
UriSchemeMailto "mailto" String
UriSchemeNews "news" String
UriSchemeNntp "nntp" String
UserEscaped True Boolean
UserInfo "" String
+ rsp {System.Net.Htt pWebResponse} System.Net.WebR esponse
+ rsp {System.Net.Htt pWebResponse} System.Net.WebR esponse
System.Net.WebR esponse 'WebResponse' is a type and cannot be used as an
expression.
System.Net.WebR esponse 'WebResponse' is a type and cannot be used as an
expression.
"Thiago Macedo" <th**********@g mail.comwrote in message
news:9c******** *************** ***********@d45 g2000hsc.google groups.com...
Cindy,

what your caller webresponse object (rsp) says about the request?

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9723
by: gizmo | last post by:
Hi, I'm using the following code to request the html source from the quoted site. ...... string url = "http://www1.soccerstand.com/"; WebRequest webRequest = WebRequest.Create(url); WebResponse webResponse = webRequest.GetResponse(); beginStr = new StreamReader(webResponse.GetResponseStream(),
3
6355
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want to keep those variables, as an alternative, as ViewState variables because I don't want to transfer to many hidden fields. This is the code I use :
8
2409
by: John K. | last post by:
Hi I was wondering if it's possible to use the WebRequest class to access a file on windows shared folder with authentication? If yes, what would the syntax be? I've tried to look this up in the references available but to no avail Also, is it safer (better practise) in an LAN environment to use HTTP requests to access shared files (via ASP.NET) rather than UNC file shares TIA Regards John
0
1113
by: IronYuppie | last post by:
Hi all-- I'm retrieving contents from my site using the retrieving images from the database method listed here: http://www.aspfree.com/c/a/ASP.NET/Retrieving-Images-from-a-Database--C---Part-II/ Basically, the page just returns the image into the page (also within the same site) that's calling it.
12
2874
by: ThyRock | last post by:
I am working on a WebRequest accessing the US Postal Service WebTools test API. This service uses a DLL file (ShippingAPITest.dll) with a query string which includes XML. The web service accepts the query string with no url encoding. I must pass the <> characters as they are in the query string. If these characters are url encoded the service rejects the request. This API Url is http://testing.shippingapis.com/ShippingAPITest.dll
0
2223
by: Gordon | last post by:
I use the following code to get source HTML. The second line seems to work when I get no response from a site. However, I want to stop the request if it's taking more than 20 - 30 seconds. I can't seem to make it work. Please point out the mistakes that I have. Thanks code............. WebRequest = WebRequest.Create(URL) WebRequest.Timeout() = RunInfo.ConnectTimeout WebResponse = WebRequest.GetResponse 'WEBRESPONSE IS A PUBLIC OBJECT...
4
1911
by: Savas Ates | last post by:
I have a vb.net web application. I want to post some variables to another web page and take some values back and process them. This is codes in my target url. I should post "langpair" cariable to my target url and it will respond with a value depend on a value which i send. <SELECT name=langpair><OPTION value=en|de>English to German</OPTION><OPTION value=en|es>English to Spanish</OPTION> </select>
2
5983
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an application to download images using System.NET classes (webclient, webrequest) asynchronously behind proxy server. The reading method works like this: System.Net.WebClient client=new System.Net.WebClient();
1
8211
by: Mr Flibble | last post by:
OK I logon to a web site and I manage to get an SMSESSION cookie that I then store in a variable called _session (a class scoping variable). I do this by calling a logon URL and setting a cookie to SMCHALLANGE=YES to allow me to obtain a session. I then iterate the cookie collection to extract the SMSESSION value. All is good (so far). This is when the sky turns grey and the rain starts to fall. I then use this SMSESSION in a web...
2
2973
by: Zytan | last post by:
I know that WebRequest.GetResponse can throw WebException from internet tutorials. However in the MSDN docs: http://msdn2.microsoft.com/en-us/library/system.net.webrequest.getresponse.aspx It only lists NotImplementedException in the Exceptions section. (Note that it does mention WebException in the Remarks section, but who knows if this is always the case for such classes, and thus perhaps they can't be trusted to always list these, and...
0
9764
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10699
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9535
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7932
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7098
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5762
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5960
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4580
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.