June 2002
Intermediate to advanced
816 pages
28h 12m
English
ContentType
stringvar = Request.ContentType
Returns a String containing the MIME type of the current client request. On GET requests, this property may return an empty string.
stringvar
A String variable to receive the content type.
The example shows how you can take different actions in your page, depending on the ContentType of the request:
Sub Page_Load( )
Dim ct As String
ct = Request.ContentType
If ct = "application/x-www-form-urlencoded" Then
'Process form input
Message.Text = "Form data was submitted."
Else
Message.Text = "Content Type of request is: " & ct
End If
End SubThe following code can be used to post to the example page:
<html>
<head>
<title>Submit a named parameter via POST</title>
</head>
<body>
<form id="form1" action="ContentType.aspx" method="POST">
<h3>Name:</h3>
<input type="text" name="name">
<input type="submit">
</form>
</body>
</html>One potential use for this property is to ensure that the content type of the request is what you expect it to be. This can help avoid wasting processor time with invalid requests and prevent malicious users from attempting to forge requests to your application that send unexpected content.
Read now
Unlock full access