Use forms authentication to restrict user rights. Then use one function to download file. What exactly do you need?
ManicCW
Junior Poster in Training
95 posts since Nov 2005
Reputation Points: 13
Solved Threads: 11
Here 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 in some module or class. Make sure it is public.
Just pass path to function. :cheesy:
And the cool thing is that it willforce download.
Hope it helps.
ManicCW
Junior Poster in Training
95 posts since Nov 2005
Reputation Points: 13
Solved Threads: 11
The 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 IO.FileInfo(path)
Hope it helps.
ManicCW
Junior Poster in Training
95 posts since Nov 2005
Reputation Points: 13
Solved Threads: 11
Where did you put this function and how did you call it?
ManicCW
Junior Poster in Training
95 posts since Nov 2005
Reputation Points: 13
Solved Threads: 11
in case anyone ever wants it, there is an excellent example of this on the photo gallery in the Personal Website Starrter Kit
jbennet
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
pandiyarajan maybe you have some bug or something that is causing aspnet_wp.exe to crash.
ManicCW
Junior Poster in Training
95 posts since Nov 2005
Reputation Points: 13
Solved Threads: 11
Then it probably exe file problem.
I will check MSDN if it has some help.
I never had need to upload or download exe file on the web. :D
ManicCW
Junior Poster in Training
95 posts since Nov 2005
Reputation Points: 13
Solved Threads: 11