How to allow null in Context.Request:
context.Response.Write(retrieveList(context.Request["SalCode"].ToString(null), context.Request["groupKeyword"].ToString(), context.Request["text"].ToString()));
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Firstly,
Request["..."]already returns astring, so there is no need to callToString()on it and thus no need to worry, at this stage, if it returnsnull(i.e. if the key is not present in the request).Thus you can call e.g.
without worrying if any of the three are null.
You can then alter
retrieveListto respond correctly if any of the inputs is null. For example, you could return null:Then, note that
Response.Writedoesn’t care if you give it anull, it just writes nothing, so you can keep the call toWriteas above.Alternatively, you could for example check the return value and write a message if it is
null: