In C# and ASP.NET, I've been sending a value to another page via Request.Querystring for years, but just recently I've come against a page error that I cannot explain.
If I send a string that has
0X
in it, then the page crashes with an error
HTTP Error 404.19 - Not Found
Also I cannot get a try / catch to work, to tell me more about the issue.
I can send a string with 0X locally in VS2022 and it traces through fine, but when pushed to the live server code, it gets this issue.
So, I knocked up the simplest of .aspx pages called QSRequest.aspx to prove the issue, but I can find no reason for it.
Here's an example that works:
QSRequest.aspx?SearchValue=KDZ2X
and the same code but doesn't work:
QSRequest.aspx?SearchValue=KDZ0X
My Page_Load code:
protected void Page_Load(object sender, EventArgs e)
{
// Get Search box value
string SearchValue = Request.QueryString["SearchValue"];
// Check if SearchValue is not null or empty
if (!string.IsNullOrEmpty(SearchValue))
{
// display the SearchValue
Label1.Text += "SearchValue: " + SearchValue;
}
else
{
Label1.Text += "<br/>No search value provided.";
}
}
On doing some research, it looks like something to do with being a protected / 'system' keyword or IIS Request Filtering (if so is there a good guide to change the settings anywhere / the correct place to edit my web.config file).
Greatly appreciate ideas if I need to encode / decode it as a work around, modify the web.config. Thanks.