I'm creating a web page which parses a text file and outputs "important" line numbers as hyperlinks that can be clicked by the user and then taken to that line number of the inputted text file. Naturally this means that by clicking the hyperlink the browser must navigate to the text file. The problem lies with that part. When the hyperlinks are clicked, nothing happens. No errors, just nothing.

Here's the relevant cshtml code:


    @for (int i = 0; i < ViewBag.links.Count; i++)
        if (ViewBag.links[i].isHyperLink == true) 
            {<a href="@ViewBag.links[i].url">@ViewBag.links[i].text</a>} //HYPERLINKS PRINTED TO PAGE HERE
        if (ViewBag.links[i].isHyperLink == false)

Here's the relevant C# code:

        MatchCollection mc = Regex.Matches(output, @", [0-9]+?\)"); //find matches in txt file
        List<TextandHyperlink> links = new List<TextandHyperlink>(); //create list of hyperlink objects
        TextandHyperlink tempLink = new TextandHyperlink(); //create 

        int length;
        string temp = "";

        // Get line numbers
        for (int i = 0; i < mc.Count; i++)
            if (i > 0)
                tempLink = new TextandHyperlink();

            length = mc[i].Value.Length;
            temp = mc[i].Value.Substring(2, length - 3);
            tempLink.text = temp;
            tempLink.url = relativePath; //ASSIGN PATH TO TXT FILE HERE
            tempLink.isHyperLink = true;
        ViewBag.links = links;

I've verified that relativePath is the correct path to the text file on my pc. Just in case, here's an example of a path I'm using: relativePath = C:\Users\USER\PROJECT\Website\Website\Home\UploadFiles~/App_Data/Uploads/bloop.txt

Thanks in advance for any help!

edit: Here is the generated html:

Error               2   at lines    (09/02/2014-06:13:32.607, <a href="C:\Users\USER\PROJECT\Website\Website\Home\UploadFiles~/App_Data/Uploads/bloop.txt">5662</a>); (09/02/2014-06:15:10.756, <a href="C:\Users\USER\PROJECT\Website\Website\Home\UploadFiles~/App_Data/Uploads/bloop.txt">7397</a>)
Timeouts                0
Inits               1   at lines    (09/02/2014-06:12:59.900, <a href="C:\Users\USER\PROJECT\Website\Website\Home\UploadFiles~/App_Data/Uploads/bloop.txt">2</a>)

Related posts

Recent Viewed