So I'm progamming ASP.NET today.
There are still some things I am not aware of. as there were many was not aware of until meeting them. Take this for example:
Somewhere in the code programmer wrote:
string requestParameterValue = context.Request[requestParameter] == null ? "": context.Request[requestParameterName].ToString();
if(requestParameterValue != "")
{
// do a GUID from the requestParameterValue ...
}
this worked until the code "meet" a piece of code writen by some other programmer. This other programmer was putting on request (on QueryString) some data to pass like clientCode - clientName. No URL Encription, no nothing !
For example (names changed for privacy issues) :
0001 - A company
0002 - Company 2
0003 - AT&T
ooops AT&T put on Query String . Great !
What happens with the queryString (a NameValueCollection ) ? If we were to pass only 0003 - AT&T the query string would be composed of:
- Key1 with valye "003 - AT" and
- another entry with the key nll and the value "T"
Now come back to the piece of code above. What happens if requestParameterName is null ? When requestParameterName is null (for some stupid key missing in an XML file), the request would still read the value of the key null.
But now, context.Request[requestParameterName] returns, waw, "T".
Creating a GUID from the string "T" is pretty difficult isn't it ?
That's a sample of how nice programming is :)
Enjoy programming !
No comments:
Post a Comment