I have a populated table from a database in my VB ASP.NET application, like so:
<dl class="row">
<dd style="width:20%; background:none;">
<%# Eval("name")%>
</dd>
<dd style="width:20%;">
<%# Eval("description")%>
</dd>
<dd style="width:30%;">
<a href="<%# Eval("templateLink")%>"><%# Eval("templateId")%></a>
</dd>
</dl>
Now, I have saved link to the template in templateLink and I’m using Guid as it’s name, namely templateId.
Now, when I click that link I want to be able to save the file, but now it does not do that. I can’t even access the file on server (on dev environment I can access but still can’t download).
This is the path I’m using.
<configuration>
<appSettings>
<add key="UploadLocation" value="C:\inetpub\wwwroot\MyProject\Intranet\Resources\"/>
</appSettings>
<configuration>
And this is the upload code:
Dim TempEx As String = System.IO.Path.GetExtension(fuTemp.FileName)
Dim TempPath As String = ConfigurationManager.AppSettings("UploadLocation")
Dim TempName As String = report.TempID.ToString + TempEx
fuTemp.PostedFile.SaveAs(TempPath + TempName)
report.TemplateLink = TempPath + TempName
As you can see, I’m saving the path to TemplateLink which I’m using later to create the a href for the table. I tried using several solutions I’ve found around the web but couldn’t make much use of it.
If possible please clarify this problem to me 🙁
Thank you.
You’ll want to store
UploadLocationas a relative path:<add key="UploadLocation" value="/Intranet/Resources/"/>In your upload code, use
Server.MapPath(ConfigurationManager.AppSettings("UploadLocation")to get the filesystem path.Then binding
TempPath + TempNameshould give you a proper HTTP link rather than a filesystem path.