0

以下行给出错误(无法将类型“string”转换为“System.Guid”)

userId = Request.QueryString["id"];

有什么解决方案可以在 http 标头 Get 中传递 Guid 变量吗?

4

1 回答 1

3
try {
    userId = new Guid(Request.QueryString["id"]);
} catch (FormatException e) {
    /*
     * It's possible that the guid is not properly formatted and an
     * exception will be thrown, so handle that here.
     */
}
于 2009-01-29T05:43:57.320 回答