Encoding og GetBytes i webrequest
Hej,jeg skal skrive en url til et webrequest. Jeg har fundet følgende på nettet, som for så vidt også fungerer fint undtagen med &-tegnet. Den skærer &-tegnet og resten væk. Jeg antager, at det er fordi &-tegnet normalt bruges til at adskille parametre i en URL, men hvordan får jeg den med i URL'en alligevel ?
/*****************************************************
* writeToURL is a method that writes the contents of
* a specified URL to the web
*****************************************************/
private static void writeToURL(WebRequest request, string data)
{
byte[] bytes = null;
// Get the data that is being posted (or sent) to the server
//bytes = System.Text.Encoding.ASCII.GetBytes(data);
bytes =
System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(data);
request.ContentLength = bytes.Length;
// 1. Get an output stream from the request object
Stream outputStream = request.GetRequestStream();
// 2. Post the data out to the stream
outputStream.Write(bytes, 0, bytes.Length);
// 3. Close the output stream and send the data out to the web
//server
outputStream.Close();
}
