I have a Asp.net application with file upload control in vb.net.In this application i can not upload more than 4 mb file.whenever i upload more than 4 mb it shows like Page Can not be Displayed Error
my Code is
Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Dim ValidAttachmentDescrption As Boolean
lblErrormsg.Visible = False
ValidAttachmentDescrption = ValidateDescription(txtAttachmentDescription.Text)
If (ValidAttachmentDescrption = False) Then
lblErrorMessage.Visible = True
lblErrorMessage.Text = "Please enter the Description"
mpeAttachment.Show()
Else
If (FileUploadControl.HasFile) Then
Try
Dim ext As String = System.IO.Path.GetExtension(FileUploadControl.PostedFile.FileName)
Dim str As String = UploadExtension
Dim OriginalDate As String = Nothing
Dim OriginalTimestring As String = Nothing
Dim strs As String() = str.Split(","c)
Dim hfc As HttpFileCollection = Request.Files
For i As Integer = 0 To hfc.Count - 1
Dim hpf As HttpPostedFile = hfc(i)
If hpf.ContentLength > 0 Then
OriginalFilename = hpf.FileName
Dim tempFilename As String() = OriginalFilename.Split("."c)
Dim Fileextension As String = tempFilename(1)
Dim datestring As DateTime = DateTime.Now().ToShortDateString()
Dim timestring1 As String = DateTime.Now().ToShortTimeString()
Dim timestring2 As String() = timestring1.Split(":"c)
OriginalTimestring = String.Format("{0}{1}{2}", timestring2(0), timestring2(1), timestring2(2))
Dim datestring1 As String = datestring
Dim datestring2 As String() = datestring1.Split("/"c)
Dim minlength As Integer = datestring2(0).Length
If minlength = 1 Then
OriginalDate = String.Format("{0}0{1}{2}", datestring2(2), datestring2(0), datestring2(1))
Else
OriginalDate = String.Format("{0}{1}{2}", datestring2(2), datestring2(0), datestring2(1))
End If
FileName = String.Format("{0}_{1}{3}.{2}", ApplicationID, OriginalDate, Fileextension, OriginalTimestring)
' _yyyyMMddhhmmss.<ext>.
'UploadExtension
Dim FiletypeArray As String() = UploadExtension.Split(","c)
Dim F1 As Integer = 0
Dim myArray As String() = New String(FiletypeArray.Count - 1) {}
For Each obj As String In FiletypeArray
Dim S1 As String = FiletypeArray(F1)
Dim S2 As String = String.Format(".{0}", S1)
F1 += 1
If obj <> Nothing Then
If OriginalFilename.EndsWith(S2) Then
ValidFiletype = True
End If
End If
Next
If hpf.ContentLength > UploadSize Then
ValidFileLength = False
Else
ValidFileLength = True
End If
'If OriginalFilename <> "" And OriginalFilename.EndsWith(".jpg") Or OriginalFilename.EndsWith(".png") Or OriginalFilename.EndsWith(".pdf") Or OriginalFilename.EndsWith(".doc") Or OriginalFilename.EndsWith(".docx") Or OriginalFilename.EndsWith(".mp3") Then
If ValidFiletype = True AndAlso ValidFileLength = True Then
'hpf.SaveAs(Server.MapPath("~/UploadFiles") + System.IO.Path.GetFileName(hpf.FileName))
Dim filePath As String = _
Server.MapPath("~/UploadFiles/" & FileUploadControl.FileName)
FileUploadControl.SaveAs(filePath)
CreateAttachment(ApplicationID, OriginalFilename, FileName, txtAttachmentDescription.Text)
SelectAttachment(ApplicationID)
Else
lblErrormsg.Visible = True
'lblErrormsg.Text = "File Extension is invalid"
lblErrormsg.Text = String.Format("File type error;we only accept{1}{0}", UploadExtension, WhiteSpace)
End If
Else
End If
Next
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
'mpeAttachment.Hide()
txtAttachmentDescription.Text = ""
lblErrorMessage.Visible = False
End If
End If
End Sub
Suggest me to solve this. Thanks in Advance