Just wondering about how to avoid Magic Strings in Querystrings? I have a lot of code like
if (string.IsNullOrEmpty(request.Form["projectId"]) ||
!int.TryParse(request.Form["projectId"],out projectId))
return null;
and naturally, I have to hardcode the projectId in the calling pages.
One way is to have a static/const "Dictionary" class that just defines a load of "QueryStringCreateProjectProjectId" identifiers, but then I have to change my JavaScript files to become server-side-generated.
Now, I realize that there is possibly no perfect solution for that because abstraction can only get to a certain extent, and at some point I have to put in strings and hope I never make a typo, but I wonder what solutions are?
Making this CW as this is borderline Poll/Subjective, but I believe that it belongs on SO.