[FIXED] [#1343] [4.2.0] Calling a DirectMethod with a null string parameter results in the string "null" on the server

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [FIXED] [#1343] [4.2.0] Calling a DirectMethod with a null string parameter results in the string "null" on the server

    Ext.Net version: 3.3.0
    ASP.Net version: 4.0.30319

    Hello,

    The behavior of DirectMethods seems to have changed since 1.7.0. Specifically, when you define a DirectMethod with a string parameter, and you call that DirectMethod with the null reference as that argument you used to get the empty string on the server. This is was an OK and understandable behavior.

    However, in Ext 3.3 you get the string "null" instead. Not the null reference, but the 4 character long string "null". This breaks our code in subtle ways and is really suprising.

    Simple page to reproduce the issue:
    <%@ Page Language="C#"  %>
    <%@ Import Namespace="Ext.Net" %>
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public void Test(string str)
        {
            if (str == null) {
                LabelStatus.Text = "str is the null reference";
            } else {
                LabelStatus.Text = "str is the text '" + str + "'";
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server"/>
            <ext:Label runat="server" ID="LabelStatus"/>
        </form>
        
        <script>
            Ext.onReady(function() {
                App.direct.Test(null);
            });
        </script>
    </body>
    </html>
    To reproduce on 1.7.x change the "App.direct" to "Ext.net.DirectMethods".

    Expected output: "str is the null reference" or "str is the text ''"
    Actual output: "str is the text 'null'"

    Thanks,
    Raphael
    Last edited by Daniil; Jun 16, 2016 at 3:48 PM.

Similar Threads

  1. Replies: 1
    Last Post: Apr 06, 2016, 12:05 PM
  2. Replies: 0
    Last Post: Nov 15, 2013, 9:32 AM
  3. [CLOSED] Submit null as value of a string parameter
    By RCN in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Dec 27, 2012, 10:55 AM
  4. [OPEN] [#29] Error "tagName is null"
    By xeo4.it in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 16, 2012, 11:25 PM
  5. Replies: 1
    Last Post: Jul 22, 2011, 5:34 PM

Posting Permissions