[英]Request.Params to String gives incomplete data
Don't know if this is a character encoding issue 不知道这是否是字符编码问题
I made a POST request to a asp.net page, I send an XML, in order to get the value into a variable I made this 我向asp.net页面发出了POST请求,我发送了XML,以便将值转换为变量,我这样做了
String selectionXml = HttpUtility.UrlDecode(Request.Params["SELECTION"]);
This is an example of my xml 这是我的xml的示例
<?xml version="1.0" encoding="UTF-8"?>
<FeatureSet>
<Layer id="0adcf012">
<Class id="MyTable">
<ID>AAAAAAAmvEA=</ID>
<ID>AAAAAAC+5EA=</ID>
</Class>
</Layer>
</FeatureSet>
The problem is, when I perform the above sentence I get this xml 问题是,当我执行以上语句时,我得到了这个xml
<?xml version="1.0" encoding="UTF-8"?>
<FeatureSet>
<Layer id="0adcf012">
<Class id="MyTable">
<ID>AAAAAAAmvEA=</ID>
<ID>AAAAAAC 5EA=</ID>
</Class>
</Layer>
</FeatureSet>
ie the second ID tag (AAAAAAC 5EA=) appears without the plus sign (+) unlike the original xml (AAAAAAC+5EA=) 也就是说,与原始xml(AAAAAAC + 5EA =)不同,第二个ID标签(AAAAAAC 5EA =)出现时没有加号(+)
How can I fix this issue? 如何解决此问题?
EDIT: I add more code, this is my asp.net page (using the mapguide library) 编辑:我添加更多的代码,这是我的asp.net页(使用mapguide库)
<%@ Page Language="C#" Debug="true" validateRequest="false"%>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Collections.Specialized" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="OSGeo.MapGuide" %>
<!-- #Include File="common.aspx" -->
<%
Response.Charset = "utf-8";
String sessionId;
String mapName;
String locale;
int target=0;
int popup=0;
String selectedLayer;
MgSelection selection = null;
sessionId = Request.Params["SESSION"];
mapName = Request.Params["MAPNAME"];
locale = Request.Params["LOCALE"];
target = int.Parse(Request.Params["TGT"]);
popup = int.Parse(Request.Params["POPUP"]);
selectedLayer = Request.Params["LAYERTARGET"];
bool todos = false;
try
{
// Initialize the Web Extensions and connect to the Server using
// the Web Extensions session identifier stored in PHP session state.
//MapGuideApi.MgInitializeWebTier (Constants.WebConfigPath);
InitializeWebTier();
MgUserInformation userInfo = new MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgMap map = new MgMap(siteConnection);
map.Open(mapName);
// ----------------------------------------------------------
// Use the following code for AJAX or DWF Viewers
// This requires passing selection data via HTTP POST
MgReadOnlyLayerCollection layers = null;
**String selectionXml = HttpUtility.UrlDecode(Request.Params["SELECTION"]);**
if (selectionXml!= null)
{
selection = new MgSelection(map, selectionXml);
layers = selection.GetLayers();
}
..........
How can I fix this issue?
如何解决此问题?
Why are you using HttpUtility.UrlDecode
? 为什么使用
HttpUtility.UrlDecode
? It's XML, not a URL! 它是XML,而不是URL! As long as you're using
POST request
you don't need the HttpUtility.UrlDecode
. 只要您使用
POST request
,就不需要HttpUtility.UrlDecode
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.