0

I work with asp.net core 2.2 (self hosted kestrel) - my app is a public portal.
I have a problem, that I don't understand...
In the app, the user can enter and store the address to his home page.
Normally this would be www.xx.yy (not matter, if it is http or https).
On a view, I have:

   <a href="@Model.cPAB_Internet" target="_blank" class="btn primary btn-primary BS_AktionsButton" >
          <i class="fas fa-globe-europe"></i>  Homepage aufrufen...
   </a>

This shows a bootstrap button with an icon, whereby @Model.cPAB_Internet contains the stored link.
Problem:
If the link only contains www.xx.yy and the button is clicked, automatically the host name and root is added before the link - e.g. http://localhost:14300/www.xx.yy and the page don't load as it is searched internally (controller method).
If the link is https://www.xx.yy, it works, if the link is http://www.xx.yy, it works and also, if the link is //www.xx.yy it works.

I have added (as bad workaround for now), that the users have to enter http:// or https:// bevor the domain, but this is not user friendly (a lot of users may not know, if they have a http or a (encrypted) https site...)

Questions:
In any browser, I can type in www.xx.yy and the browser resolves the correct link...

  • Why does this not work in a asp.net core view?
  • Is there a workaround, to bring that to work?

Thanks for any answer.

FredyWenger
  • 2,236
  • 2
  • 32
  • 36

1 Answers1

0

It seems, as this is the standard behavior of html (nothing special related to asp.net core here).
I have found another posting to HTML.
So... I leaf the check (leading https:// or http://) in my code to store the data.
At least http:// is changed automatically to https:// at runtime, if the domain is encrypted (the homepage is also loaded, if the user does a mistake and type http:// instead of https://).

Similar question to HTML

FredyWenger
  • 2,236
  • 2
  • 32
  • 36