HttpWebRequest 上 MediaType 属性的有效值是什么

Bob*_*tiz 4 html asp.net webrequest httpwebrequest

HttpWebRequest 上 MediaType 属性的有效值是什么?

我想做这样的事情:

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)))
Run Code Online (Sandbox Code Playgroud)

谢谢。

And*_*ose 6

我认为这个维基百科页面应该给你一个相当全面的媒体类型列表:
媒体类型

  • IANA 官方列表(比@andy-rose 的 WIKI 链接更新)位于:http://www.iana.org/assignments/media-types/media-types.xhtml (2认同)