473,383 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to read Request Body values in ASP.NET

I am trying to read Http request body values NOT form values
The content type is text/xml and its POST
I am posting data from Infopath to an asp.net page.

In ASP it works by just writing Response.Write(request) the same does not
work in ASP.NET

I tried using Rquest.BinaryrRead() and Request.InputStream but it gives me
text values as space separated (eg Karthik yyyy aaaa) whereas the data i am
looking out for is in XML format.
When I tried saving the Request object to a file using
Request.SaveAs("c:\\request.txt, false), it file contained xml text in the
format which I required.
In ASP too I get this xml string easily by get getting the request object.

Help me with a solution.

Thanks,
Karthik
Dec 8 '05 #1
6 9662
What if you use "view source" instead of just looking at the text in a
browser (remember that the browser will ignore unkown tags).

Else explains a bit more what you are doing when you are not saving the file
(for now I assume you displayed the result in your browser as an HTML
cotnent type).

--
Patrice

"Karthik" <Ka*****@discussions.microsoft.com> a écrit dans le message de
news:AA**********************************@microsof t.com...
I am trying to read Http request body values NOT form values
The content type is text/xml and its POST
I am posting data from Infopath to an asp.net page.

In ASP it works by just writing Response.Write(request) the same does not
work in ASP.NET

I tried using Rquest.BinaryrRead() and Request.InputStream but it gives me
text values as space separated (eg Karthik yyyy aaaa) whereas the data i am looking out for is in XML format.
When I tried saving the Request object to a file using
Request.SaveAs("c:\\request.txt, false), it file contained xml text in the
format which I required.
In ASP too I get this xml string easily by get getting the request object.

Help me with a solution.

Thanks,
Karthik

Dec 8 '05 #2
I want to read the xml data which is there in the request body, do some
process and insert into a database.
Currently, I am unable to read the xml data in the request body, unless i
save it to a file and then read the file.

Karthik

"Patrice" wrote:
What if you use "view source" instead of just looking at the text in a
browser (remember that the browser will ignore unkown tags).

Else explains a bit more what you are doing when you are not saving the file
(for now I assume you displayed the result in your browser as an HTML
cotnent type).

--
Patrice

"Karthik" <Ka*****@discussions.microsoft.com> a écrit dans le message de
news:AA**********************************@microsof t.com...
I am trying to read Http request body values NOT form values
The content type is text/xml and its POST
I am posting data from Infopath to an asp.net page.

In ASP it works by just writing Response.Write(request) the same does not
work in ASP.NET

I tried using Rquest.BinaryrRead() and Request.InputStream but it gives me
text values as space separated (eg Karthik yyyy aaaa) whereas the data i

am
looking out for is in XML format.
When I tried saving the Request object to a file using
Request.SaveAs("c:\\request.txt, false), it file contained xml text in the
format which I required.
In ASP too I get this xml string easily by get getting the request object.

Help me with a solution.

Thanks,
Karthik


Dec 8 '05 #3
How do you post those data (as a file or as a field ?). How do you read this
content ?

At this point I believe you'll have to provide the minimal amount of code
that repro the problem (and it"s likely you'll discover what gores wrong in
this process).

--

"Karthik" <Ka*****@discussions.microsoft.com> a écrit dans le message de
news:AE**********************************@microsof t.com...
I want to read the xml data which is there in the request body, do some
process and insert into a database.
Currently, I am unable to read the xml data in the request body, unless i
save it to a file and then read the file.

Karthik

"Patrice" wrote:
What if you use "view source" instead of just looking at the text in a
browser (remember that the browser will ignore unkown tags).

Else explains a bit more what you are doing when you are not saving the file (for now I assume you displayed the result in your browser as an HTML
cotnent type).

--
Patrice

"Karthik" <Ka*****@discussions.microsoft.com> a écrit dans le message de
news:AA**********************************@microsof t.com...
I am trying to read Http request body values NOT form values
The content type is text/xml and its POST
I am posting data from Infopath to an asp.net page.

In ASP it works by just writing Response.Write(request) the same does not work in ASP.NET

I tried using Rquest.BinaryrRead() and Request.InputStream but it gives me text values as space separated (eg Karthik yyyy aaaa) whereas the data i
am
looking out for is in XML format.
When I tried saving the Request object to a file using
Request.SaveAs("c:\\request.txt, false), it file contained xml text in

the format which I required.
In ASP too I get this xml string easily by get getting the request object.
Help me with a solution.

Thanks,
Karthik


Dec 8 '05 #4
I post the data from an Infopath form.
In the ASP.Net page i use the following code.
str = Request.InputStream;
strLen = int.Parse(str.Length.ToString());
byte[] strArr = new byte[strLen];
strRead = str.Read(strArr,0,strLen);
Response.Write(System.Text.Encoding.ASCII.GetStrin g(strArr, 0, strLen));

// this print Karthik aaa bbb cccc

I want data in this format, data taken from saved request object for which i
used
System.Web.HttpContext.Current.Request.SaveAs("c:\ \request.txt",false);

<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution
solutionVersion="1.0.0.7" productVersion="11.0.6565" PIVersion="1.0.0.0"
href="file:///C:\Documents%20and%20Settings\J910472\My%20Documen ts\financedeclaration.xsn"
name="urn:schemas-microsoft-com:office:infopath:financedeclaration:-myXSD-2005-05-20T03-34-42"
?><?mso-application progid="InfoPath.Document"?><my:myFields
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-05-20T03:34:42"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">
<my:txtEmployeeName>Karthik</my:txtEmployeeName>
<my:txtEmployeeCode>0000</my:txtEmployeeCode>
<my:txtPANNumber>Applied</my:txtPANNumber>
<my:Gender>Male</my:Gender>
<my:txtResidentialAddress>skjfdkfjdkf dfjkfjdf</my:txtResidentialAddress>
<my:blnRentedHouse>false</my:blnRentedHouse>
<my:txtHouseLocated>dddd</my:txtHouseLocated>
<my:txtRentPerMonth>0.0</my:txtRentPerMonth>
<my:txtMonthsinRentedHouse>0</my:txtMonthsinRentedHouse>
<my:txt80D>0.0</my:txt80D>
<my:txt80DD>0.0</my:txt80DD>
<my:txt80DDB>0.0</my:txt80DDB>
<my:txt80E>0.0</my:txt80E>
<my:txt80G>0.0</my:txt80G>
<my:txt80GG>0.0</my:txt80GG>
<my:txtOther>0.0</my:txtOther>
<my:txtPensionFund>0.0</my:txtPensionFund>
<my:txtNSC>0.0</my:txtNSC>
<my:txtPPF>0.0</my:txtPPF>
<my:txtIB>0.0</my:txtIB>
<my:txtCE>0.0</my:txtCE>
<my:txtHLP>0.0</my:txtHLP>
<my:txtInsurance>0.0</my:txtInsurance>
<my:txtOtherDeduction>0.0</my:txtOtherDeduction>
<my:blnHouseOccupied>true</my:blnHouseOccupied>
<my:blnLoanB41999>true</my:blnLoanB41999>
<my:txtRentfromHouse>0.0</my:txtRentfromHouse>
<my:txtLoanInterest>0.0</my:txtLoanInterest>
<my:Note></my:Note>
</my:myFields>

Thanks,
Karthik
"Karthik" wrote:
I am trying to read Http request body values NOT form values
The content type is text/xml and its POST
I am posting data from Infopath to an asp.net page.

In ASP it works by just writing Response.Write(request) the same does not
work in ASP.NET

I tried using Rquest.BinaryrRead() and Request.InputStream but it gives me
text values as space separated (eg Karthik yyyy aaaa) whereas the data i am
looking out for is in XML format.
When I tried saving the Request object to a file using
Request.SaveAs("c:\\request.txt, false), it file contained xml text in the
format which I required.
In ASP too I get this xml string easily by get getting the request object.

Help me with a solution.

Thanks,
Karthik

Dec 8 '05 #5
Ok, have you tried my first suggestion ?

Here it looks like you are writing the XML file inside an HTML page. As XML
tags are not recognized as valid HTML Tags by the browsers they are just not
shown in your output.

So use "View source" in your browser to see what the actual content of the
page instead of relying on what you see in your browser... Do you see those
tags when using "View source" ?

--
Patrice

"Karthik" <Ka*****@discussions.microsoft.com> a écrit dans le message de
news:83**********************************@microsof t.com...
I post the data from an Infopath form.
In the ASP.Net page i use the following code.
str = Request.InputStream;
strLen = int.Parse(str.Length.ToString());
byte[] strArr = new byte[strLen];
strRead = str.Read(strArr,0,strLen);
Response.Write(System.Text.Encoding.ASCII.GetStrin g(strArr, 0, strLen));

// this print Karthik aaa bbb cccc

I want data in this format, data taken from saved request object for which i used
System.Web.HttpContext.Current.Request.SaveAs("c:\ \request.txt",false);

<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution
solutionVersion="1.0.0.7" productVersion="11.0.6565" PIVersion="1.0.0.0"
href="file:///C:\Documents%20and%20Settings\J910472\My%20Documen ts\financede
claration.xsn" name="urn:schemas-microsoft-com:office:infopath:financedeclaration:-myXSD-20
05-05-20T03-34-42" ?><?mso-application progid="InfoPath.Document"?><my:myFields
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-05-20
T03:34:42" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us"> <my:txtEmployeeName>Karthik</my:txtEmployeeName>
<my:txtEmployeeCode>0000</my:txtEmployeeCode>
<my:txtPANNumber>Applied</my:txtPANNumber>
<my:Gender>Male</my:Gender>
<my:txtResidentialAddress>skjfdkfjdkf dfjkfjdf</my:txtResidentialAddress>
<my:blnRentedHouse>false</my:blnRentedHouse>
<my:txtHouseLocated>dddd</my:txtHouseLocated>
<my:txtRentPerMonth>0.0</my:txtRentPerMonth>
<my:txtMonthsinRentedHouse>0</my:txtMonthsinRentedHouse>
<my:txt80D>0.0</my:txt80D>
<my:txt80DD>0.0</my:txt80DD>
<my:txt80DDB>0.0</my:txt80DDB>
<my:txt80E>0.0</my:txt80E>
<my:txt80G>0.0</my:txt80G>
<my:txt80GG>0.0</my:txt80GG>
<my:txtOther>0.0</my:txtOther>
<my:txtPensionFund>0.0</my:txtPensionFund>
<my:txtNSC>0.0</my:txtNSC>
<my:txtPPF>0.0</my:txtPPF>
<my:txtIB>0.0</my:txtIB>
<my:txtCE>0.0</my:txtCE>
<my:txtHLP>0.0</my:txtHLP>
<my:txtInsurance>0.0</my:txtInsurance>
<my:txtOtherDeduction>0.0</my:txtOtherDeduction>
<my:blnHouseOccupied>true</my:blnHouseOccupied>
<my:blnLoanB41999>true</my:blnLoanB41999>
<my:txtRentfromHouse>0.0</my:txtRentfromHouse>
<my:txtLoanInterest>0.0</my:txtLoanInterest>
<my:Note></my:Note>
</my:myFields>

Thanks,
Karthik
"Karthik" wrote:
I am trying to read Http request body values NOT form values
The content type is text/xml and its POST
I am posting data from Infopath to an asp.net page.

In ASP it works by just writing Response.Write(request) the same does not work in ASP.NET

I tried using Rquest.BinaryrRead() and Request.InputStream but it gives me text values as space separated (eg Karthik yyyy aaaa) whereas the data i am looking out for is in XML format.
When I tried saving the Request object to a file using
Request.SaveAs("c:\\request.txt, false), it file contained xml text in the format which I required.
In ASP too I get this xml string easily by get getting the request object.
Help me with a solution.

Thanks,
Karthik

Dec 8 '05 #6
Thanks Patrice. It works..
I somehow overlooked it.

Karthik

"Patrice" wrote:
Ok, have you tried my first suggestion ?

Here it looks like you are writing the XML file inside an HTML page. As XML
tags are not recognized as valid HTML Tags by the browsers they are just not
shown in your output.

So use "View source" in your browser to see what the actual content of the
page instead of relying on what you see in your browser... Do you see those
tags when using "View source" ?

--
Patrice

"Karthik" <Ka*****@discussions.microsoft.com> a écrit dans le message de
news:83**********************************@microsof t.com...
I post the data from an Infopath form.
In the ASP.Net page i use the following code.
str = Request.InputStream;
strLen = int.Parse(str.Length.ToString());
byte[] strArr = new byte[strLen];
strRead = str.Read(strArr,0,strLen);
Response.Write(System.Text.Encoding.ASCII.GetStrin g(strArr, 0, strLen));

// this print Karthik aaa bbb cccc

I want data in this format, data taken from saved request object for which

i
used
System.Web.HttpContext.Current.Request.SaveAs("c:\ \request.txt",false);

<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution
solutionVersion="1.0.0.7" productVersion="11.0.6565" PIVersion="1.0.0.0"

href="file:///C:\Documents%20and%20Settings\J910472\My%20Documen ts\financede
claration.xsn"

name="urn:schemas-microsoft-com:office:infopath:financedeclaration:-myXSD-20
05-05-20T03-34-42"
?><?mso-application progid="InfoPath.Document"?><my:myFields
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-05-20
T03:34:42"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"

xml:lang="en-us">
<my:txtEmployeeName>Karthik</my:txtEmployeeName>
<my:txtEmployeeCode>0000</my:txtEmployeeCode>
<my:txtPANNumber>Applied</my:txtPANNumber>
<my:Gender>Male</my:Gender>
<my:txtResidentialAddress>skjfdkfjdkf dfjkfjdf</my:txtResidentialAddress>
<my:blnRentedHouse>false</my:blnRentedHouse>
<my:txtHouseLocated>dddd</my:txtHouseLocated>
<my:txtRentPerMonth>0.0</my:txtRentPerMonth>
<my:txtMonthsinRentedHouse>0</my:txtMonthsinRentedHouse>
<my:txt80D>0.0</my:txt80D>
<my:txt80DD>0.0</my:txt80DD>
<my:txt80DDB>0.0</my:txt80DDB>
<my:txt80E>0.0</my:txt80E>
<my:txt80G>0.0</my:txt80G>
<my:txt80GG>0.0</my:txt80GG>
<my:txtOther>0.0</my:txtOther>
<my:txtPensionFund>0.0</my:txtPensionFund>
<my:txtNSC>0.0</my:txtNSC>
<my:txtPPF>0.0</my:txtPPF>
<my:txtIB>0.0</my:txtIB>
<my:txtCE>0.0</my:txtCE>
<my:txtHLP>0.0</my:txtHLP>
<my:txtInsurance>0.0</my:txtInsurance>
<my:txtOtherDeduction>0.0</my:txtOtherDeduction>
<my:blnHouseOccupied>true</my:blnHouseOccupied>
<my:blnLoanB41999>true</my:blnLoanB41999>
<my:txtRentfromHouse>0.0</my:txtRentfromHouse>
<my:txtLoanInterest>0.0</my:txtLoanInterest>
<my:Note></my:Note>
</my:myFields>

Thanks,
Karthik
"Karthik" wrote:
I am trying to read Http request body values NOT form values
The content type is text/xml and its POST
I am posting data from Infopath to an asp.net page.

In ASP it works by just writing Response.Write(request) the same does not work in ASP.NET

I tried using Rquest.BinaryrRead() and Request.InputStream but it gives me text values as space separated (eg Karthik yyyy aaaa) whereas the data i am looking out for is in XML format.
When I tried saving the Request object to a file using
Request.SaveAs("c:\\request.txt, false), it file contained xml text in the format which I required.
In ASP too I get this xml string easily by get getting the request object.
Help me with a solution.

Thanks,
Karthik


Dec 8 '05 #7

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

Similar topics

0
by: Majordomo | last post by:
-- >>>> --36742377 **** Command '--36742377' not recognized. >>>> Content-Type: text/plain; charset=us-ascii **** Command 'content-type:' not recognized. >>>> Content-Transfer-Encoding: 7bit...
15
by: Håkan Persson | last post by:
Hi. I am trying to set up a simple HTTP-server but I have problems reading data that is beeing POSTed. class httpServer(BaseHTTPServer.BaseHTTPRequestHandler): def do_POST(self): input =...
2
by: Sean Dotson | last post by:
I have a form that passes variables to an asp file and then uploads a file. For some reason the request.form is not getting the info from the form. It's returning blanks. Any insight would be...
0
by: ronaldlee | last post by:
I got a collection read only error, below is the error message. Collection is read-only. Description: An unhandled exception occurred during the execution of the current web request. Please...
7
by: Carl | last post by:
these are three files below : submit.html <html> <head> </head> <body> <form action="redirect.php" method="POST" > <input type="text" name="value" value="test" > <input type="submit" >...
9
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to...
1
by: JohnathanKong | last post by:
Hello, I hope this is the right place to post, but anyways, here goes. I current have a forum, snitz, in place, but am having an IE specific problem. Basically what happens is, I have a page that...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.