I have an index view of cards (e.g. playing cards) laid out in a BootStrap grid. Each card is in a div, and I have a jQuery click handler for each div, to open a details page for any card (card div) that is clicked. So the redirect from the index to detail view is all accomplished using this (rather smelly) JavaScript:
var showDetail = function (index) {
const newUrl = "@($"http://{Model.HostName}{Url.Action("Details", "Card")}/")" + index;
window.location = newUrl;
};
I don't like to depend on the Razor code nugget to give me the hostname and the url's path. Does JavaScript have any functionality that I can use to achieve the same as the above dodgy code?
URLctor requires aurlparameter, and if its value is a relative URL, it also requires abaseURL parameter. To provide that base url, I will still need to use$"http://{Model.HostName}, where I don't want any hard coding. How do I adjust for SSL?$('<a>', { "href" : relativeUrl}).prop('href ')