G
Guest
Problem with Upload Error handling
When the user uploads the file greater than the length specified in
web.config/machine.config, I always see the DNS Error page eventhough I have
handled the error Page_Error Event.
And this is my code in Page_Error event,
Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Error
Dim ex As Exception = Server.GetLastError.GetBaseException
If TypeOf (ex) Is HttpException Then
Dim oEx As HttpException = CType(ex, HttpException)
If oEx.ErrorCode = -2147467259 Then
Dim ErrorLabel As New Label
ErrorLabel.ForeColor = System.Drawing.Color.Red
ErrorLabel.Text = "La dimensione del file supera la
dimensione massima consentita di 4MB"
Dim oCell As New HtmlTableCell
oCell.Controls.Add(ErrorLabel)
trUpload.Cells.Add(oCell)
Server.ClearError()
Response.ClearHeaders()
Response.Status = "200 OK"
Response.End()
Else
Throw New ApplicationException(oEx.Message, oEx)
End If
Else
Throw New ApplicationException(ex.Message, ex)
End If
End Sub
I tried to set later just to get rid of DNS Error
Response.Status = "200 OK"
Response.End()
But in vain.
Can anyone shed some light on this? Why so Response.Status does not work?
TIA,
Holy
When the user uploads the file greater than the length specified in
web.config/machine.config, I always see the DNS Error page eventhough I have
handled the error Page_Error Event.
And this is my code in Page_Error event,
Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Error
Dim ex As Exception = Server.GetLastError.GetBaseException
If TypeOf (ex) Is HttpException Then
Dim oEx As HttpException = CType(ex, HttpException)
If oEx.ErrorCode = -2147467259 Then
Dim ErrorLabel As New Label
ErrorLabel.ForeColor = System.Drawing.Color.Red
ErrorLabel.Text = "La dimensione del file supera la
dimensione massima consentita di 4MB"
Dim oCell As New HtmlTableCell
oCell.Controls.Add(ErrorLabel)
trUpload.Cells.Add(oCell)
Server.ClearError()
Response.ClearHeaders()
Response.Status = "200 OK"
Response.End()
Else
Throw New ApplicationException(oEx.Message, oEx)
End If
Else
Throw New ApplicationException(ex.Message, ex)
End If
End Sub
I tried to set later just to get rid of DNS Error
Response.Status = "200 OK"
Response.End()
But in vain.
Can anyone shed some light on this? Why so Response.Status does not work?
TIA,
Holy