gpt4 book ai didi

c# - Querystring 中的 Guid 正在以某种方式进行转换

转载 作者:太空狗 更新时间:2023-10-29 18:00:15 25 4
gpt4 key购买 nike

我不确定为什么会这样,但这里有一些细节可能有助于找到解决方案:

  • 它似乎在大多数计算机上都能正常工作 firefox 和 IE
  • 某些 Guids 在其他 Guids 工作时发生
  • 我们将防火墙设置为监控模式,但仍然发生

这是 PageModify.aspx 中构建查询字符串的行:

Response.Redirect(string.Format("Editor.aspx?id={0}", pageId,
CultureInfo.CurrentCulture));

当一切正常时,这是查询字符串的输出:

https://example.com/Editor.aspx?id=1dfz342b-3a4d-4255-8054-93916324afs6

这是重定向到 Editor.aspx 时在浏览器中查看的内容:

https://example.com/Editor.aspx?id=1dfz342b-3a4d-xxxxxxxxxxxxxxx324afs6

当这一行运行时,我们当然会得到一个无效的 guid 错误:

_PageEditId= new Guid(Request.QueryString["id"]);

有人看过吗?可能是IIS设置?这里没有做任何特别的事情,每个人的系统都有相同的基线。它发生在内部和外部客户身上。

最佳答案

A GuidStructure , 所以当它作为 String 穿过查询字符串时你必须解析它:

Guid PageEditId = Guid.Parse(Request.QueryString["id"]); //add null checks or use TryParse

关于c# - Querystring 中的 Guid 正在以某种方式进行转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8066121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com