如何在导航方法中转义post参数中的特殊字符

本文关键字:post 参数 特殊字符 转义 导航 方法 | 更新日期: 2023-09-27 18:18:19

我有类似的要求张贴在这个问题。如何打开IE与post信息在c# ?

对于同样的问题,我尝试使用Andy S提供的答案。然而,我面临的问题是我需要发送2个参数(在我的情况下请求哈希),我不确定如何使用webbrowser的导航方法实现这一点。

我尝试通过将字符串作为"Request=ABC&Hash=123"来传递Post数据,服务器似乎没有识别参数。

下面是有效的HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Document Retrieval Service Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>    
<body onLoad="document.form1.submit();">
<form name="form1" method="post" action="http://abc.com/GetDoc/GetDoc.aspx">
    <!--Request: -->       
    <input name="Request" type="hidden" id="request" value="ABC">
<!--Hash:-->
   <input name="Hash" type="hidden" id="hash" value="123">
</form>
</body>
</html>

编辑:我能够通过传递额外的参数来导航方法,按照这个问题提供的答案c# Post浏览器失败,有什么想法吗?

然而,现在我面临的下一个问题是我在请求参数中有特殊字符& & &;。我尝试在请求参数上使用System.Security.SecurityElement.Escape,但是,它仍然不能识别其他参数。

编辑2:我可以使用system . web . httutility . urlencode而不是使用System.Security.SecurityElement.Escape

谢谢,Prabhjot

如何在导航方法中转义post参数中的特殊字符

我可以使用system . web . httutility . urlencode而不是使用System.Security.SecurityElement.Escape