4

Just having a problem trying to properly display an image from an external site but mvc constraints links and automatically adds the localhost: url at the start of everything even with custom routing this cannot be avoided

eg I require: www.google.com/finance/chart?q=NYSE:V&tlf=12

but i am getting: http://localhost:3022/www.google.com/finance/chart?q=NYSE:V&tlf=12

any help would be much appreciated

1
  • Could you just type here some Code how you're getting the URL because it might be a String Concat issue and/or Relative path issue. Commented Jan 6, 2012 at 11:17

2 Answers 2

8

Your problem is not MVC; it is the formation of your <a> tags. You are doing it like this:

<a href="www.google.com/finance/chart?q=NYSE:V&tlf=12">blah...</a>

You should be doing it like this:

<a href="http://www.google.com/finance/chart?q=NYSE:V&tlf=12">blah...</a>

Without including the protocol at the beginning, the browser assumes your link is relative to the current site. It has nothing whatsoever to do with MVC.

Sign up to request clarification or add additional context in comments.

1 Comment

This answer applies for both <a href=""> and <img src="">, as well as any other HTML tag attribute which accepts a URI value.
0

If you require a link on a separate domain, you need to add http://

So :

http://www.google.com/finance/chart?q=NYSE:V&tlf=12

Should work!

Why? Without the http, the link is considered relative and the browser uses the relative domain -> localhost!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.