Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are valid values for the MediaType Property on a HttpWebRequest

What are valid values for the MediaType Property on a HttpWebRequest?

I want to do something like this:

Dim url As String = HttpContext.Current.Request.Url.AbsoluteUri
Dim req As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(New Uri(url)), System.Net.HttpWebRequest)
' Add the current authentication cookie to the request 
Dim cookie As HttpCookie = HttpContext.Current.Request.Cookies(FormsAuthentication.FormsCookieName)
Dim authenticationCookie As New System.Net.Cookie(FormsAuthentication.FormsCookieName, cookie.Value, cookie.Path, HttpContext.Current.Request.Url.Authority)

req.CookieContainer = New System.Net.CookieContainer()
req.CookieContainer.Add(authenticationCookie)
req.MediaType = "PRINT"

Dim res As System.Net.WebResponse = req.GetResponse()
'Read data 
Dim ResponseStream As Stream = res.GetResponseStream()
'Write content into the MemoryStream
Dim resReader As New BinaryReader(ResponseStream)
Dim docStream As New MemoryStream(resReader.ReadBytes(CInt(res.ContentLength)))

Thanks.

like image 837
Bobby Ortiz Avatar asked Dec 30 '09 20:12

Bobby Ortiz


People also ask

What is the use of HttpWebRequest in C#?

The HttpWebRequest class provides support for the properties and methods defined in WebRequest and for additional properties and methods that enable the user to interact directly with servers using HTTP.

What is the difference between HttpWebRequest and WebRequest?

The main difference is that HttpWebRequest is an HTTP client, and HttpRequest is server side to be used in an ASP.NET web application. about WebRequest I got.


1 Answers

I think this wikipedia page should give you a fairly comprehensive list of media types:
Media Types

like image 124
Andy Rose Avatar answered Oct 22 '22 13:10

Andy Rose