I am downloading pdf files directly from a folder 'uploads' in the root of the website, using the basic code below for test.
This displays the files as a live hyperlink as required, however, when clicked to open the file; Error not found; Error 404 Requested URL: /Newsletter1.pdf. The uploads folder path seems to be missing, preventing the selected files from being viewed. I have changed the UrlFields and TextFields to 'FullName' which does display the full root of the files, but now although displayed as live links they are no longer active.
I have tried a multitude of variations without success. Can anyone Help please?
Code:
<script type="text/vbscript" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim dirInfo as New DirectoryInfo(Server.MapPath("~/uploads/"))
articleList.DataSource = dirInfo.GetFiles("*")
articleList.DataBind()
End Sub
</script>
<body>
<form id="form1" runat="server">
<asp:GridView runat="server" id="articleList"
AutoGenerateColumns="False"
HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="name" DataTextField="name"
HeaderText="Newsletter Files"/>
</Columns>
</asp:GridView>
</form>
</body>