简体   繁体   English

Request.Params到String提供不完整的数据

[英]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.

相关问题 Braintree测试Request.Params始终为空 - Braintree test Request.Params always empty Request.Params将字符“ +”替换为“”(空格).net - Request.Params is replacing character “+” for “ ” (whitespace) .net Request.Params和Request.Form何时不同? - When do Request.Params and Request.Form differ? 为什么Request.Params不喜欢垂直/管道栏| - Why Request.Params Does not Like the Vertical/Pipe Bar | 无法从C#中的Request.Params中读取值 - unable to read values from Request.Params in c# Request["key"] vs Request.Params["key"] vs Request.QueryString["key"] - Request["key"] vs Request.Params["key"] vs Request.QueryString["key"] 使用C#,当请求流中有文件时,如何有条件地隔离Request.Params? - Using C#, how do I conditionally isolate Request.Params when there is a File in the request stream? asp.net 3.5中的Request.Params和Request.Forms中的保留键数量是多少 - How much is the number of reserved keys in Request.Params and Request.Forms in asp.net 3.5 为什么任何对Server.MapPath()的引用都会杀死我的HttpContext Request.Params []? - Why does any reference to Server.MapPath() kill my HttpContext Request.Params[]? 无法从使用 Azure SAML SSO 配置的本地应用程序中的 C# 中的 Request.Params 获取 SAMLResponse - Unable to get SAMLResponse from Request.Params in C# from onpremise app configured with Azure SAML SSO
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM