By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,360 Members | 3,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,360 IT Pros & Developers. It's quick & easy.

How to read Request Body values in ASP.NET

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.