[CLOSED] 2.0/2.1 Direct method problem

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] 2.0/2.1 Direct method problem

    Hi Daniil/Geoffrey,

    We posted similar question in the community forum and please see the attached solution (Please change the example.txt to example.zip and unzip).
    The following are what happened:
    1, It is working for the pre-2.0 release. (2.0.4499.24809 in March or April)
    2. For 2.0, we got Bad Response (2.0.0.0)
    3. For 2.1, we got : 'App.direct' is null or not an object (2.1.0.23691)

    Thanks,
    Last edited by Daniil; Oct 18, 2012 at 6:41 PM. Reason: [CLOSED]
  2. #2
    Hi @gets_gui,

    Please post a required code to reproduce the problem directly here wrapping in code tags. Please simplify as much as you can.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @gets_gui,

    Please post a required code to reproduce the problem directly here wrapping in code tags. Please simplify as much as you can.
    I attached the zip file (example.txt) for the whole solution in the initial post.
    Since I can not upload zip file, I renamed the example.zip to example.txt.
    You can download the attached file. rename it to example.zip, unzip and load/run the solution.
    BTW, I didn't bundle the ext.dll because of the upload size limitation in the forum.

    Let me know if you have any question.
  4. #4
    Looks like someone removed the attachment in the original post.
    I can assure you that there is no virus or malware.
    Let me know if you need the individual files.
    BTW, we are using MVC.
  5. #5
    Please review the forum guidelines:

    http://forums.ext.net/showthread.php...ing-New-Topics

    http://forums.ext.net/showthread.php...ation-Required

    Please create a very simplified sample and post in the forums, making sure to wrap your code samples in [CODE] tags. Any code posted as an attachment will be removed. We can only review code posted inline and code that has been simplified. If you post 300+ lines of code for a sample that can be demonstrated in <100 lines, your post may go unanswered.

    Please spend a few minutes to narrow down the problem and focus the sample only on the problem. Please remove all code that is not related to the problem. Once you've removed all unnecessary code, then remove some more. Please repeat until only the code required to reproduce the problem remains.
    Geoffrey McGill
    Founder
  6. #6
    Ok, understood.
    I was trying to make it easy for you guys to debug.

    Anyway, we are using MVC.

    The view is copied from your example:
    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public void UnhandledException()
        {
            throw new Exception("Unhandled Exception");
        }
    
        [DirectMethod]
        public void CatchException()
        {
            try
            {
                throw new Exception("An Exception was Thrown");
            }
            catch(Exception e)
            {
                Ext.Net.ResourceManager.AjaxSuccess = false;
                Ext.Net.ResourceManager.AjaxErrorMessage = e.Message;
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>DirectMethod and UserControls - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager runat="server" />
            
            <h1>Handling Exceptions in [DirectMethod]</h1>
            
            <div class="information">
                <p>The <code>DirectMethodNamespace</code> property has been set to "<b>CompanyX</b>" on the &lt;ext:ResourceManager> which overrides the default <code>[DirectMethod]</code> Namespace value of "<b>App.direct</b>".</p>
            </div>
            
            <h2>Dealing with [DirectMethod] Exceptions and request failure</h2>
            
            <p>&nbsp;</p>
            
            <h3>Example</h3>
               
            <ext:Button ID="Button1" runat="server" Text="Unhandled Exception">
                <Listeners>
                    <Click Handler="App.direct.UnhandledException({ failure: function (msg) { Ext.Msg.alert('Failure', msg); } });" />
                </Listeners>
            </ext:Button>
            
            <br />
            
            <ext:Button ID="Button2" runat="server" Text="Catch Exception">
                <Listeners>
                    <Click Handler="App.direct.CatchException({ failure: function (msg) { Ext.Msg.alert('Failure', msg); } });" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
    Here is the controller code:
    using System;
    using System.Web.Mvc;
    
    namespace Ext.Net.MVC.Controllers
    {
        [HandleError]
        public class HomeController : System.Web.Mvc.Controller
        {
    
    
            public ActionResult Index()
            {
                return this.View();
            }
    
    
        }
    }
  7. #7
    What is it that we're supposto be looking at here? Where's the problem. I see the following note:

    The DirectMethodNamespace property has been set to "CompanyX" on the &lt;ext:ResourceManager> which overrides the default [DirectMethod] Namespace value of "App.direct".
    But, I don't see "CompanyX" defined anywhere in the sample?
    Geoffrey McGill
    Founder
  8. #8
    This is copied from your example.
    https://examples2.ext.net/#/Events/D...ds/Exceptions/
    I just removed DirectMethodNamespace="CompanyX" from <ext:ResourceManager>.

    What happened to us is:
    Once clicked any of those two buttons, we got App.direct is null in 2.1 and Bad Response error in official 2.0 release.
    However, as I mentioned in the original post, it is working for 2.0 pre release code.
    Of course, the similar code is working in 1.x.

    And I hope you understand that the reason we sent the whole solution originally is that we are afraid you can not reproduce this problem in your environment.
  9. #9
    Quote Originally Posted by gets_gui View Post
    "The DirectMethodNamespace property has been set to "CompanyX" on the <ext:ResourceManager> which overrides the default [DirectMethod] Namespace value of "App.direct"."

    I just removed DirectMethodNamespace="CompanyX" from <ext:ResourceManager>.
    We asked several times that you remove anything that is not related to the problem. We ask that because when you leave stuff in the sample that is not related to the problem, it can create confusion. If it's not related to the problem, remove it.

    This is copied from your example.
    https://examples2.ext.net/#/Events/D...ds/Exceptions/
    You copied a WebForms sample into a MVC project. The sample is not going to work in an MVC project.

    It may have worked in the past, but it was just a hack and rendering of the DirectMethods has changed in v2.1. Client side proxies for the DirectMethods are now only rendered if configured in the Controller.

    Within the SVN repository (/trunk/), there is a new MVC Examples Explorer. This new MVC specific Examples Explorer contains several [DirectMethod] samples. Also, several MVC DirectMethod samples have been posted to the forums.

    Hope this helps.
    Last edited by geoffrey.mcgill; Oct 17, 2012 at 8:45 PM.
    Geoffrey McGill
    Founder
  10. #10
    Geoffrey,

    The reason why we posted this example is that, we are not using any razor view in our codebase. But, we have to use webform (MVC) so that we can use Ext.Net 1.5. My understanding is that in order for DirectMethod to work in v2.1, we have to port it to razor view so that we can use direct method.

    I am very confused right now.

    Thanks.


    Quote Originally Posted by geoffrey.mcgill View Post
    We asked several times that you remove anything that is not related to the problem. We ask that because when you leave stuff in the sample that is not related to the problem, it can create confusion. If it's not related to the problem, remove it.



    You copied a WebForms sample into a MVC project. The sample is not going to work in an MVC project.

    It may have worked in the past, but it was just a hack and rendering of the DirectMethods has changed in v2.1. Client side proxies for the DirectMethods are now only rendered if configured in the Controller.

    Within the SVN repository (/trunk/), there is a new MVC Examples Explorer. This new MVC specific Examples Explorer contains several [DirectMethod] samples. Also, several MVC DirectMethod samples have been posted to the forums.

    Hope this helps.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  2. [CLOSED] how to call direct method
    By tactime10 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 04, 2012, 8:38 AM
  3. [CLOSED] Direct Method in UX
    By dev in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 30, 2012, 12:32 PM
  4. Direct method and direct event over SSL?
    By dimitar in forum 1.x Help
    Replies: 0
    Last Post: Oct 08, 2011, 8:09 PM
  5. Replies: 8
    Last Post: Jan 25, 2011, 4:21 AM

Posting Permissions