I have some code that I've inherited in jquery in an asp.net MVC project. I'm not exactly sure of the specifics of what it's doing are, but in general it's redirecting to another page. It works fine in Chrome, but when I run it in IE 11, I get an error. Can someone help me?
The issue seems to be in using the @Html.Raw
method. In IE, it shows an error saying that there is an invalid character:
JavaScript critical error at line 26, column 37 in http://localhost:1436/Scripts/javascript/Timeout.js\n\nSCRIPT1014: Invalid character
If I remove the @ symbol, I get a message saying that HTML is undefined.
I'm not sure what the new URI part is about, so I'm hesitant to remove the HTML.Raw method. How do I use HTML.Raw in IE?
Alternatively, how can I rewrite this command while still keeping whatever the URI part is doing?
Here's the jquery function:
//Current time is greater than the expiry time
if (Date.parse(currentTime) > timeForExpiry) {
alert("Session expired. You will be redirected to welcome page");
window.applicationBaseUrl = @Html.Raw(HttpUtility.JavaScriptStringEncode(
new Uri(
new Uri(this.Context.Request.Url.GetLeftPart(UriPartial.Authority)),
Url.Content("~/")
).ToString(), true))
window.location = window.applicationBaseUrl + "Admin/Logout";
}