A Way to Validate an Enum Passed in a QueryString
// Declare a variable that you want to store your validated
// enum value in.
CommandBehavior cmdBehavior;
try
{
// Validate the enum with a try/catch
string cmdBehaviorRequest = Request.QueryString["cmdBehavior"];
cmdBehavior = (cmdBehavior)Enum.Parse(
typeof(cmdBehavior), cmdBehaviorRequest, true);
}
catch
{
// Set to default or whatever other handling you want.
cmdBehavior = DEFAULT_CMD_BEHAVIOR;
}