I have an app that sends some field values from a selected record to an add record page by means of querystring parameters.
Here's some relevant code:
XVar data = ajax.getCurrentRecord();
string StockNo = data["StockNo"].ToString();
string Description = data["ItemDescription"].ToString();
string Category = data["Category"].ToString();
result["url"] = MVCFunctions.GetTableLink("ShoppingCart", "Add", "StockNo=" + StockNo + "&Description=" + Description + "&Category=" + Category);
It was working great until we encountered someone trying to order an item with the character "#" in the Description field. The URL was properly encoded, except for that # character, causing the URL to get truncated at that point and not allowing the field values beyond that character to get passed to the add form. Here's what the URL looked like:
I attempted to remedy the situation by wrapping the querystring with HttpContext.Current.Server.UrlEncode(). That fixed the issue with the "#" character, but unfortunately, it replaced the spaces with a plus sign "+" which threw a 404.11 error:
HTTP Error 404.11 - Not Found
The request filtering module is configured to deny a request that contains a double escape sequence.
Any advice on how I can make this work?
[EDIT] I now see other issues with the encoded string in the second example, so I guess UrlEncode() wasn't the right approach. I'm at a loss as to how to get the "#" character to not break my URL.