Home > Net >  Issue passing query string with browsers
Issue passing query string with browsers

Time:09-17

I'm currently in the process of making sure an older MVC4 site that was built and primarily ran using IE11 works for other browsers. The first we're testing against is Edge Chromium, but we encountered an issue where a popup happens.

When the popup occurs, we pass a query string like so:

http://localhost/Gen/DataExport?cntId=100&InitialLoad=True&showProgress=False&startExport=False

where

  • cntId is our record identifier
  • InitialLoad is a true/false value letting the system know this is the first time the user is in the page (it does some operations that requires the page refreshing)
  • showProgress is a true/false value letting the system know to show the progress of certain operations (we don't show when first loading the page)
  • startExport is a true/false value telling the system when to export certain data (not used initially)

Back in the Controller code, we have an HttpGet method for loading the page. The method receives cntId, InitialLoad, showProgress, and startExport.

Everything works as expected when using IE11. The passed in parameters arrive and are read correctly.

However, the issue we have found is when Edge Chromium, Chrome, and Firefox try to load the page, the query string arrives with incorrect data.

Each of the browsers show that cntId is 100, but InitialLoad is false for some reason.

I'm at a loss why this one page does not pass parameters correctly, while all the others do. It could be due that the system is opening a new window possibly, but I'm unsure.

EDIT:

I'm going to be more explicit here since a few people can't read my question, along with the tags for this question.

This is an MVC4 application, using C# on the backend and hooked to an Oracle DB. It is a project that is used by a government entity, who still uses IE11.

IE11's support runs out in August. Obviously, said government entity needs to still use this MVC4 application. Hence why I'm trying to make sure it works in Edge (Chromium version), Chrome, Firefox, and Safari.

Now that the nonsense is out of the way, on to examples of my code. I have a View with a link on it. The link calls a Javascript function that proceeds to open a popup window. The code is the following:

function OpenGen() {
    var url = '@Url.Action("DataExport", "Gen", new { cntId = @Session["cntId"], InitialLoad = true, showProgress = false, startExport = false })';
    //Open the new window for the Gen
    window.open(url, "GenWindow", 'height='   screen.height   ',width='   screen.width   ',resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=yes');
}

After the link is clicked, the server executes the following code in the GenController:

[HttpGet]
public ActionResult DataExport([Optional, DefaultParameterValue(-1)]int cntId,
        [Optional, DefaultParameterValue(false)]bool InitialLoad,
        [Optional, DefaultParameterValue(false)]bool showProgress,
        [Optional, DefaultParameterValue(false)]bool startExport)
{
    if (InitialLoad)
    {
        ...
    }
}

I am debugging on the if statement for InitialLoad. The parameters passed in when using IE11 are correct.

cntId = 100, InitialLoad = true, showProgress = false, startExport = false

However, when debugging for Edge, Chrome, Firefox, and Safari, I get the following parameters:

cntId = 100, InitialLoad = false, showProgress = false, startExport = false

I'm unsure why Edge, Chrome, Firefox, and Safari are losing the parameters. The url for the four is the same as IE11's.

Now, with that said, any thoughts on this issue would be welcomed.

CodePudding user response:

I figured out the issue. For some odd reason, Edge, Chrome, Firefox, and Safari were not dealing with the '&' properly. I know that ampersand is a value that gets encoded but it's weird that each browser couldn't decode it on their own. When I dumbed it down for them, it worked.

IE11 was the only one dealing with it for some odd reason.

Regardless, it's just a weirdness with the parameters not getting dealt with specifically when opening a popup.

  • Related