Removing localhost url in asp mvc

It’s just that there is a problem trying to correctly display the image from an external site, but mvc restricts links and automatically adds localhost: url at the beginning of everything, even using custom routing, this cannot be avoided

For example, I need: www.google.com/finance/chart?q=NYSE:V&tlf=12

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

any help would be much appreciated

+4
source share
2 answers

Your problem is not MVC; this is tagging <a> . You do it like this:

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

You should do it like this:

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

Without enabling the protocol at the beginning, the browser assumes that your link refers to the current site. It has nothing to do with MVC.

+6
source

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

So:

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

Must work!

Why? Without http link is considered relative, and the browser uses the relative domain β†’ localhost !

0
source

Source: https://habr.com/ru/post/1389636/


All Articles