asp.Net HREF Link to a .pdf file outside wwwroot falls over - C not a registered profile

Posted on 2011-04-21
Last Modified: 2012-05-11

I'm trying to build a document management/library system where users link to .pdf documents. The document name, reference and path to the selected document are stored in an Access database.

I originally set the document path to point to a directory c:\documentation but when I click on the hyperlink I gt the message "c is not a registered profile"

If I move the document to the same directory on the webserver as the aspx file the link works but this arrangement isn't practical.

How do I make a link to a location outside the webserver virtual directory?

The code is below:

<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server" Debug="true">

      sub Page_Load(obj as Object, e as EventArgs)

            Dim strCriterion as String
            strCriterion = "WorkInst9001"

            'Set Up Connection
            dim objConn as new OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Document\Documentation.mdb")

            'Open Connection
            dim objCmd as new OleDbDataAdapter ("SELECT txtDocumentReference, txtDocumentName, txtDocumentPath FROM tblDocumentation WHERE txtCatShortCut LIKE '" & strCriterion & "'", objConn)

            'Fill Dataset
            dim dsISOCategory as DataSet = new DataSet()
            objCmd.Fill(dsISOCategory, "tblDocumentation")

            'Select Data View and Bind to Server Control
            MyDataList.DataSource = dsISOCategory.Tables("tblDocumentation").DefaultView
      end sub

      <table valign="top" height="100%" cellspacing=0 cellpadding=0>
            <tr height="100%">
                  <td valign="top">
                        <ASP:DataList id="MyDataList" RepeatDirection="Vertical" runat="Server">
                                    <DIV style="padding:15,15,15,15;font-size:12pt;font-family:Arial">
                                                <a href=<%# DataBinder.Eval(Container.DataItem, "txtDocumentPath")%> target="_blank"><%# DataBinder.Eval(Container.DataItem, "txtDocumentName")%></a>
Question by:Crxfrd
    LVL 8

    Accepted Solution

    Open IIS and right-click on the website.  Add Virtual Directory and select your path.  That's it.

    Author Closing Comment

    Thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
    In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now