3

So a long long time ago we added MVC 1.0 to an existing ASP.NET 2.0 WebForms site and during that upgrade we made MVC's UrlHelper available to our existing WebForms code. This meant that within our WebForms code we could do such things as:

<%= Url.Content("~/this/is/nice") %>

to output the Url

mysite.com/this/is/nice

which was nice and worked great.

Fast forward to more recent times and we're looking to move our application to a new home (new servers) and the above functionality is now misbehaving, now:

<%= Url.Content("~/this/is/nice") %>

now outputs

mysite.com/webforms/location/this/is/nice

as if the physical location is the application root - and I've no idea why and have been unsuccessful in recreating it on my development machine.

Does anyone out there what can possibly be the cause of this? I've been stuck on this problem for the past few days now and am nearly out of ideas. The only glimmer of hope I have right now is that the problem occurs on my colleague's environment so it's definitely an issue we can recreate.

Update: it doesn't happen on all WebForms pages - just certain ones and the only differing characteristic I've noticed so far is that it's occurring on a page where some Url rewriting is going on.

Cain
  • 918
  • 6
  • 9
  • 1
    "we made MVC's UrlHelper available to our existing WebForms code" How did you do that? Is it the real UrlHelper from MVC or did you basically recreate its functionality? – Chris Pratt Jul 14 '14 at 17:09
  • We just added a 'Url' property to a base page which all our WebForms inherited from and the property would spin up an instance of a UrlHelper on first use. – Cain Jul 14 '14 at 17:27

1 Answers1

0

I would switch from using the MVC method:

<%= Url.Content("~/this/is/nice") %>

To one of the Web Forms methods that does the same thing:

<%#ResolveClientUrl("~/this/is/nice")%>
<%#ResolveUrl("~/this/is/nice")%>

ResolveUrl returns a path relative to the site root, whereas ResolveClientUrl returns a path relative to the current page.

  • Hmmm, interesting. Thanks for the suggestion but we've already got a workaround in place. I'd still like to get to the root of the issue though. It 'feels' like a configuration issue or some patch not being installed... – Cain Jul 16 '14 at 09:11