Testing library for .aspx page in C#

G

Giulio Petrucci

Hi there,

I'm quite new to such this kind of things (i.e. ASPX, web programming
and so on) so don't mind if my question might sound a bit "stupid"...

I need to build a test suit for an .aspx page. The aim of the test is
the following: having some strings like:
"variable=comma_separated_list_of_values", I should send them to my
..aspx page as query string of GET request AND as payload data of POST
requests too. When I use the GET requests I don't have any problem,
using POST I'm experiencing some troubles instead. The code I use is the
following:

Uri uri = new Uri(...ilmiouri...);
HttpWebRequest r = (HttpWebRequest)WebRequest.Create(uri);
byte[] bytes = Encoding.UTF8.GetBytes(data);
r.ContentType = "text/html; charset=utf-8";
r.ContentLength = bytes.Length;
Stream s = r.GetRequestStream(); //Here comes my exception...
s.Write(bytes, 0, bytes.Length);
s.Close();
HttpWebResponse response = (HttpWebResponse)r.GetResponse();

at line "Stream s = r.GetRequestStream()" I have:

System.Net.ProtocolViolationException
Cannot send a content-body with this verb-type.
at System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream)
at System.Net.HttpWebRequest.GetRequestStream()
at CodFis.Test.Request.Send(String method, String data) in
C:\Documents and Settings\blablabla...

Can anyone help me to solve these problems or suggest me an alternative
approach to perform such these tests?

Thanks in advance.
Have a nice day/week,
Giulio - Italia
 
M

Mr. Arnold

Can anyone help me to solve these problems or suggest me an alternative
approach to perform such these tests?

You might want to post to MS.Public.dotnet.framework.aspnet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top