JS files
1. Add below method to get exact host name.
function extractHostname(url) {var host = new URL(url).hostname;
return host;}
2. Use above method in the issue finding.
var domain = 'localhost'; //add exact domain name or IP address
var loginUrl = 'define the login Url here';
var currentUrl = $(location).attr("href");
var host = extractHostname(currentUrl);if (host === domain)
{
$(location).attr("href", loginUrl + "?returnurl=" + currentUrl );
}
$(location).attr("href", loginUrl + "?returnurl=" + currentUrl );
}
else
{
alert("Invalid Return URL");
}
.CS file
private bool IsLocalUrl(string url)
{
if (string.IsNullOrEmpty(url))
{
return false;
}
else
{
return ((url[0] == '/' && (url.Length == 1 ||
(url[1] != '/' && url[1] != '\\'))) ||
(url.Length > 1 &&
url[0] == '~' && url[1] == '/'));
}
}
if (IsLocalUrl(strRedirectUrl))
{
returnUrl = strRedirectUrl
}
No comments:
Post a Comment