请看下面的代码。它在 handler.asxh
中。
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
new RequestManagementFacade().PinRequest(Int32.Parse(context.Request.QueryString["requestId"]), (Boolean.Parse(context.Request.QueryString["isPinned"])));
}
这显示了以下错误:
Value cannot be null. Parameter name: String
当我检查上下文请求查询字符串时,有值被传递,但是,代码在这个阶段中断。
此处理程序将连接到业务逻辑层。
最佳答案
There is value being passed as i have checke dthe context request query string
我强烈怀疑你的诊断不正确。值(value)观不会神奇地消失——你需要质疑你的假设。虽然这很容易调试。我建议将您的代码更改为:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
string requestId = context.Request.QueryString["requestId"];
string isPinned = context.Request.QueryString["isPinned"];
var facade = new RequestManagementFacade();
facade.PinRequest(Int32.Parse(requestId), Boolean.Parse(isPinned));
}
然后真的很容易一步一步地找出正在发生的事情。
关于c# - 值不能为空。参数名称 : String,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13702212/