Using a Javascript function, I pass in the URL I want to redirect to in Chrome browser to the function called redirect2MainLookup. Each time it prepends the current page directory to the redirect location, and gives the following error:
Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /LookupCodes/Edit/~/LookupCodes/Character.cshtml
Below is the function where I have tried many of the redirect options found at How do I redirect to another webpage?
HTML: '''
onclick="redirect2MainLookup('~/LookupCodes/Character.cshtml')">@Page.Title'''
Javascript function:
function redirect2MainLookup(primaryFilename) {
alert("Inside redirect2MainLookup Function value = " +
primaryFilename);
//location=primaryFilename;
alert("Location = " + primaryFilename);
//window.location.href = primaryFilename;
window.location.replace(primaryFilename);
//$(location).attr('href', primaryFilename);
};
My expectation is that ~/LookupCodes/Character.cshtml will be passed to the function for the redirect, WITHOUT /LookupCodes/Edit/ before it.