簡體   English   中英

Request.Params到String提供不完整的數據

[英]Request.Params to String gives incomplete data

不知道這是否是字符編碼問題

我向asp.net頁面發出了POST請求,我發送了XML,以便將值轉換為變量,我這樣做了

String selectionXml = HttpUtility.UrlDecode(Request.Params["SELECTION"]);

這是我的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>

問題是,當我執行以上語句時,我得到了這個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>

也就是說,與原始xml(AAAAAAC + 5EA =)不同,第二個ID標簽(AAAAAAC 5EA =)出現時沒有加號(+)

如何解決此問題?

編輯:我添加更多的代碼,這是我的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();
      }

      ..........

如何解決此問題?

為什么使用HttpUtility.UrlDecode 它是XML,而不是URL! 只要您使用POST request ,就不需要HttpUtility.UrlDecode

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM