Recommended Answers
Jump to PostUse forms authentication to restrict user rights. Then use one function to download file. What exactly do you need?
Jump to PostHere is my function for downloading file:
Public Sub DownloadFile(ByVal path As String) With HttpContext.Current Dim file As IO.FileInfo = New IO.FileInfo(.Server.MapPath(path)) If file.Exists Then .Response.Clear() .Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name) .Response.AddHeader("Content-Length", file.Length.ToString()) .Response.ContentType = "application/octet-stream" .Response.WriteFile(file.FullName) .Response.End() End If End With End Sub
Put this function …
Jump to PostThe error is very clear. You are passing absolute path instead of relative. Pass string like "~/MyFiles/MyFile.doc". If you want to use absolute path then fix code like this:
Instead of:
Dim file As IO.FileInfo = New IO.FileInfo(.Server.MapPath(path))
Put this:
Dim file As IO.FileInfo = New …
Jump to PostThanks for giving the code to download the file.
But when I am using in my application. i am getting the error like this
"Server Application Unavailable"
Upon seeing the event log it says
"aspnet_wp.exe stopped unexpectedly". do you know why it is stopping.
All 14 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.