Naty Bizz
Naty Bizz

Reputation: 2342

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

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

This is an example of my 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 version="1.0" encoding="UTF-8"?>
<FeatureSet>
<Layer id="0adcf012">
<Class id="MyTable">
<ID>AAAAAAAmvEA=</ID>
<ID>AAAAAAC 5EA=</ID>
</Class>
</Layer>
</FeatureSet>

i.e. the second ID tag (AAAAAAC 5EA=) appears without the plus sign (+) unlike the original xml (AAAAAAC+5EA=)

How can I fix this issue?

EDIT: I add more code, this is my asp.net page (using the mapguide library)

<%@ 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();
      }

      ..........

Upvotes: 0

Views: 550

Answers (1)

Yair Nevet
Yair Nevet

Reputation: 13013

How can I fix this issue?

Why are you using HttpUtility.UrlDecode? It's XML, not a URL! As long as you're using POST request you don't need the HttpUtility.UrlDecode.

Upvotes: 1

Related Questions