We have a report with a Navigate to Url Action on a cell. The Url generated consists of a time range where the times specified are DateTimeOffsets. We discovered an issue where times with a non-negative time zone offset would result in an incorrect Url string. The root cause of this was due to the '+' in the '+00:00' portion of the DateTimeOffset not being UrlEncoded as it should be and resulted in a space instead of a plus.
I believe this may be a bug/issue in how Telerik's Report Viewer generates the Url when the report is generated. I believe it is not properly escaping all characters that should be escaped in a Url.
Our solution is to create a User Function called UrlEncode which receives a string and returns the results of the C# WebUtility.UrlEncode() function. This standard .Net function properly UrlEncodes all necessary characters in the string. The only limitation I've seen is that it is new as of .NET 4.5. (Here is the MSDN documentation for this method: https://msdn.microsoft.com/en-us/library/system.net.webutility.urlencode.aspx)
I've detailed an example below.
With:
A start date of 04/07/2015 13:29:32 +00:00
An end date of 04/07/2015 13:34:25 +00:00
The following is the original version of the Target Url expression used to generate the Url in the Navigate To Url action. This resulted in the '+' portion of a positive time zone offset being replaced by a space in the resulting Url:
= '../RptExternal?' +
'sDate=' + Fields.StartDate.ToString() +
'&eDate=' + Fields.EndDate.ToString()
This resulted in a Url such as:
http://localhost/RptExternal?sDate=2015/04/07%2013:29:32%20+00:00&eDate=2015/04/07%2013:34:25%20+00:00
While relatively easy to decipher visually, our ASP.NET MVC web app would receive that and translate the URL incorrectly by replacing each occurrence of a '+' with a space.
With the solution described above, the following is the working version of the Target Url expression used to generate the Url in the Navigate To Url action:
= '../RptExternal?' +
'sDate=' + Reporting.Helper.UserFunctions.UrlEncode(Fields.StartDate.ToString()) +
'&eDate=' + Reporting.Helper.UserFunctions.UrlEncode(Fields.EndDate.ToString())
This results in a Url such as:
http://localhost/RptExternal?sDate=2015%2F04%2F07+13%3A29%3A32+%2B00%3A00&eDate=2015%2F04%2F07+13%3A34%3A25+%2B00%3A00
Which our web app receives and properly translates the date times into valid DateTimeOffsets as expected.