Timeline for SSJS Platform.Response.Redirect() throws unknown error: Error in Application
Current License: CC BY-SA 4.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 16, 2020 at 20:23 | vote | accept | shd.lux | ||
Jul 13, 2020 at 4:45 | history | edited | Gortonington | CC BY-SA 4.0 |
added 198 characters in body
|
Jul 12, 2020 at 17:03 | comment | added | Gortonington |
Yeah the desc var is just to see if its a redirect exception. Not a url to redirect to via the functuon, so the Redirect will not contain any newline chars in it. That is inside the else conditional to redirect to an explicitly stated url if any other error than the redirect one from the try statement. I am confused on the relevance of your argument. If you mean when passing the param of e in the url, then it is passed as a string not a newline so its passed as \n not newline
|
|
Jul 12, 2020 at 14:19 | comment | added | shd.lux | But I think it is pointless to go on with this discussion as you used desc just for testing purpose... | |
Jul 12, 2020 at 14:13 | comment | added | shd.lux | I understand how objects are working... the string contains new line characters such as \n which Redirect do not allow as I described in my comment. You can try it for yourself by using "Platform.Response.Redirect('google.com\n',false)" | |
Jul 12, 2020 at 11:09 | comment | added | Gortonington |
2. Like I said, it is not necessary but it certainly is an option to choose. In your stated case with testing, sure makes sense to keep it temporary - but I more was mentioning this for production. If your site is permanently going to be redirecting elsewhere (which it seems like it will), then you should make sure the final result shows it as a permanent redirect via true
|
|
Jul 12, 2020 at 11:01 | comment | added | Gortonington |
1. that is the full e object. If you notice in my code, I do ` var desc = e.description;` which will only grab the "description" part of the object, which is the (using your example) "System.ArgumentException: Redirect URI cannot contain newline characters. - from Jint\r\n\r\n" part. See here for more info on how that works (w3schools.com/js/js_objects.asp)
|
|
Jul 11, 2020 at 22:06 | comment | added | shd.lux | 2: If you set the second param true, in some browsers, testing becomes harder as the redirect is a 301 and without clearing the browser cache the redirect can be hard set inside the browser not allowing you to test anymore the page itself. Also, I believe there are only a very few cases where a 301 on a CloudPage would make sense as the Redirect is used to move from one page to another rather telling the browser the resource is not there anymore | |
Jul 11, 2020 at 22:02 | comment | added | shd.lux | I disagree with you here. 1: Without Stringify you will get: {"message":"Redirect URI cannot contain newline characters.","description":"System.ArgumentException: Redirect URI cannot contain newline characters. - from Jint\r\n\r\n"}. | |
Jul 10, 2020 at 14:33 | comment | added | Gortonington |
and as to the JInt part. You can just change it to look at the indexOf the important part, like if(desc.indexOf('ExactTarget.OMM.AMPScriptRedirectException') > -1) {
|
|
Jul 10, 2020 at 14:28 | comment | added | Gortonington |
desc is set to pull the description from the e object, so it will return the string value associated with the description property. There should be no need to Stringify it. And setting to false is an option if you want, but not necessary. I have successfully used and tested the above in my instance without error.
|
|
Jul 10, 2020 at 14:02 | comment | added | shd.lux | Thanks Gortonington. Your example is great but I believe you would need to stringify the desc in the catch redirect as otherwise this will cause an error. Also, I would set redirect 2nd parameter to false so it becomes a 302 rather a permanent 301. Last but not least you get 'OMMCommon' while I get 'Jint'. I have changed it to a include() | |
Jul 8, 2020 at 12:59 | history | undeleted | Gortonington | ||
Jul 8, 2020 at 12:59 | history | edited | Gortonington | CC BY-SA 4.0 |
added 1215 characters in body
|
Jul 7, 2020 at 13:55 | history | deleted | Gortonington | via Vote | |
Jul 7, 2020 at 13:22 | history | answered | Gortonington | CC BY-SA 4.0 |