i have button download, the button download will transferring file into the browser.
the file will not transferred when the file size is more than 10 Mb.
this will never occurs if the file size is less than 10 Mb.
please suggest me whats wrong with me ? or please suggest me if i shall config my IIS server ?
this is my code :
Protected Sub button_download_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button_download.Click
table = "TABLE"
sql = "SELECT FILE_NAME FROM DOCUMENT WHERE ID_DOCUMENT = '" & id_document & "' ORDER BY FILE_NAME ASC"
dataset = eclass.dataset(sql, table)
Dim file_name = dataset.Tables(table).Rows(0)("FILE_NAME")
Dim file_path = Request.MapPath("") & "\document\" + file_name
Dim file As New FileInfo(file_path)
If file.Exists Then
Response.ClearContent()
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "text/plain"
Response.TransmitFile(file.FullName)
Response.[End]()
End If
end sub
The maxRequestLength indicates the maximum file upload size supported by ASP.NET, the maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. Hence, we need to set both maxRequestLength and maxAllowedContentLength values
to upload large files.
So, you need to add the following code in web.config:
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
53 Points
101 Posts
my Response.TransmitFile not working when the file size is more than 10 MB
Jul 06, 2017 07:18 AM|wibowowiwit|LINK
Hi guys,
i have button download, the button download will transferring file into the browser.
the file will not transferred when the file size is more than 10 Mb.
this will never occurs if the file size is less than 10 Mb.
please suggest me whats wrong with me ? or please suggest me if i shall config my IIS server ?
this is my code :
Thank & Regards.
Wibowo Wiwit
Star
8670 Points
2882 Posts
Re: my Response.TransmitFile not working when the file size is more than 10 MB
Jul 07, 2017 02:47 AM|Cathy Zou|LINK
Hi wibowowiwit
The maxRequestLength indicates the maximum file upload size supported by ASP.NET, the maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. Hence, we need to set both maxRequestLength and maxAllowedContentLength values to upload large files.
So, you need to add the following code in web.config:
Then use the code below:
Related links:
https://forums.iis.net/t/1169846.aspx
https://stackoverflow.com/questions/18480556/downloading-zip-file-with-maximum-file-size-limit
https://stackoverflow.com/questions/43804446/c-sharp-download-big-file-from-server-with-less-memory-consumption
Best regards
Cathy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.