Re: file download
- From: "Bala" <Bala@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 2 Oct 2005 12:36:02 -0700
Hi
The problem is impersonate got failure. But now i change the code, now the
impersontate is working fine. but its not dowloading the file. I have the
file on F drive and the sub folder having all the access to that particular
domain user.
after impersonate i writen the username, its shows the current username and
also its show the excat file path F:\Test\test foder\file1.pdf
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name())
This is the code I am using.. but its not downloading the file. I dont know
where the problem is.
code:
If impersonateValidUser(Session("WinLogin"), "ScanFiles.local",
Session("WinPassword")) Then
Dim spath As String
DownloadFile(CType(E.Item.Cells(0).Controls(0),
HyperLink).NavigateUrl, True)
undoImpersonation()
Else
' impersonation failed.
Response.Write("not ok")
End If
'-------------------------------
Private Sub DownloadFile(ByVal fname As String, ByVal forceDownload As
Boolean)
Dim path1 As String = fname
Dim name As String = Path.GetFileName(path1)
Dim ext As String = Path.GetExtension(path1)
Dim type As String = "Application/pdf"
If forceDownload Then
Response.AppendHeader("content-disposition", "attachment;
filename=" & name)
Else
Response.AppendHeader("content-disposition", "inline;
filename=" & name)
End If
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name())
Response.WriteFile(path1)
Response.End()
End Sub
"Peter Rilling" wrote:
> Where did you put the files. Most likely they are in a folder that does not
> have the same permission ACLs that the rest of the website does. Make sure
> that the physical folders of where you are placing the file have the same
> security as the root folder for your site.
>
> "Bala" <Bala@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:50994DEF-1A5F-4F99-AC66-53D3F072D8B0@xxxxxxxxxxxxxxxx
> > Hi
> >
> > Thanks for the reply. Noww when I click the download button, its asking me
> > windows username and password window, Once i type the username with domain
> > and password, its download the file. when i clicked next files, its
> > download
> > the files without asking password. so where is the problem?
> >
> > Thanks
> > bala
> >
> > "Peter Rilling" wrote:
> >
> >> The browser cannot access files that are not under the virtual root.
> >>
> >> Either move your files under the virtual root, or create some proxy web
> >> page
> >> that can access the files (for instance, you might have the page
> >> download.aspx?filename=test.pdf).
> >>
> >> "Bala" <Bala@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:3744631E-2268-418C-B248-5F8D76E6AB0B@xxxxxxxxxxxxxxxx
> >> > Hi
> >> >
> >> > I displaying my pdf files ( F:\test\test1\test.pdf - for example file
> >> > path)
> >> > on datagrid for user download.
> >> > when I right clik the link and its show like this
> >> > file:///F:/test/test1/test.pdf.
> >> > But the problem is its not dowloading the file. I am impersontating the
> >> > my
> >> > domain user account. I am sure there is simple mistake, but I cannt
> >> > find
> >> > that
> >> > one. anyone please help me. can i use server.mappath?
> >> >
> >> >
> >> > Thanks
> >> > Balakumar
> >>
> >>
> >>
>
>
>
.
- References:
- Re: file download
- From: Peter Rilling
- Re: file download
- From: Peter Rilling
- Re: file download
- Prev by Date: Re: Using Cache expiration to invoke Delegates...
- Next by Date: Re: Datagrid dynamically generated template columns dissapearing
- Previous by thread: Re: file download
- Next by thread: Visual Studio / DOCTYPE
- Index(es):