4

I have to debug an old VB.NET 2.0 code of someone who has left the company. We have a production system (let us call it http://prod) and a test system (http://test). Both are nearly similiar including a documents repository. When looking at docs in production, all the hyperlinks showing up at the bottom are okay (meaning they say something like http://prod/download.ashx?id={GUID}).

However in test it is the same (http://prod/download.ashx?id={GUID}), even it should be http://test/download.ashx?id={GUID} instead.

After hours of debugging I have found the relevant line of code:

html += "<td><a href='" + HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.PathAndQuery, "/") + "int/download.ashx?id=" + row.Item(0).ToString() + "' target='_blank' class='" + row.Item(3).ToString() + "'>" + row.Item(1).ToString() + "</a>" + privat + "</td><td>" + row.Item(2).ToString() + "</td>"

Looking at html this shows i.e.

"<table class='table_dataTable'><thead><tr><td>Name</td><td>Jahr</td></tr></thead><tbody><tr><td><a href='http://prod/int/download.ashx?id=4d280886-db88-4b25-98d8-cf95a685d4a4' target='_blank' class='doc'>Document for managers</a></td><td>2014</td>"

So I wonder, where does this come from incorrectly? I may have found the relevant part of coding, but I am not sure, what to do now, respectively if I am right on this?:

Public Class download : Implements IHttpHandler, IReadOnlySessionState
    Dim debug As String = ""
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Dim fehler As String = ""
        Try
            ' Get the file name from the query string
            Dim queryFile As String = context.Request.QueryString("id")
            debug += "id=" + queryFile + "<br>"

Any help is appreciated as VB.NET is not my main focus.

Joey
  • 511
  • 6
  • 20
  • `HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.PathAndQuery, "/")` is coming out as what? That would be initial thought on the wrong URL though it could also be that the html variable has some replace run on it later that takes out the test URLs. – JB King Nov 02 '15 at 16:01
  • It is saying `'http://prod/int/`. How does this help? – Joey Nov 02 '15 at 16:21
  • If that is the case, then I'd wonder what before that method is causing the configuration issue with the link. Consider how this narrows down where in the code the issue could be found for how this helps. – JB King Nov 02 '15 at 16:24
  • If I would have found the relevant part of the code myself, I would not have asked this question here ;-). – Joey Nov 03 '15 at 08:07
  • Now the question is what could have updated the HttpContext to have the wrong URL information in it that is the next round in this process. There can be a lot of work getting to the core of an issue and I have limited experience in VB.Net, I'm trying to give ideas and suggestions here. Note that this is still comments and not answers I've given. – JB King Nov 03 '15 at 15:44
  • That code looks workable; like it's not the problem. Perhaps you have already hopped over to the prod site due to a different link that's wrong. Try using your browser's F12 tools to see all requested URLs as you navigate the test site. – Tom Blodget Nov 12 '15 at 05:52

1 Answers1

0

You have probably checked this but sometimes the obvious gets overlooked.

  1. Verify the URL in your browser window. Make sure it has not changed to http://prod... while you were navegating.

  2. Verify that your web application is not using frames. The page in question could be loaded in a frame using the prod URL. If this is the case your web.config might have a setting to say where this frame is loaded from or it might simply be hardcoded.

  3. Check for URL Rewrite rules in IIS or your web.config