DirectMethod request fails in hosting service

  1. #1

    DirectMethod request fails in hosting service

    Hi,

    I have the following code in my Login.aspx view:
                Ext.net.DirectMethod.request({
                    url: "/Account/Login/",
                    cleanRequest: true,
                    params: {
                        "liveAccount": account,
                        "ReturnUrl": Ext.urlDecode(String(document.location).split('?')[1]).r || '/'
                    },
                    failure: function (errorMessage, response, extraParams, o) {
                        log("Usuário com conta " + user.emails.account + " não tem autorização para acessar essa página. Por favor contactar o administrador");
                    }
                });
    This calls the following method in my controller:
            [AcceptVerbs(HttpVerbs.Post)]
            [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
                Justification = "Needs to take same parameter type as Controller.Redirect()")]
            public ActionResult Login(string liveAccount, string returnUrl = null)
            {
                if (repo.getClienteIDParaUsuario(liveAccount) == -1)
                {
                    return new AjaxResult { ErrorMessage = "Acesso não permitido para a conta " + liveAccount + "." };
                }
    
                HttpCookie cookie = new HttpCookie("ClienteID");
                cookie.Value = repo.getClienteIDParaUsuario(liveAccount).ToString();
                cookie.Expires = DateTime.Now.AddMonths(1);
                HttpContext.Response.Cookies.Add(cookie);
    
                this.FormsAuth.SignIn(liveAccount, true);
    
                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return this.Redirect(returnUrl.Replace("default.aspx", ""));
                }
    
                return this.RedirectToAction("Home", "Index");
            }
    This code works fine in localhost, but when I push it to appharbor,
    I get a failed response 200 with message "BADRESPONSE: syntax error"

    Does anyone know why this happens??

    Thanks,
  2. #2
    Try to replace 'Ext.net.DirectMethod' by 'Ext.Ajax'
    I guess 'Ext.net.DirectMethod' is not required in your case (AjaxResult must be used for direct request)
  3. #3

    Not working

    When I change Ext.net.DirectMethod for Ext.Ajax,
    the method is fired but the reponse does not redirect to any page.
    Did I missed some configuration that should be used with Ext.Ajax?
    I tis the first time that I use it in my application...
  4. #4

    Same error for ext.net mvc demo application

    I just pushed Ext.Net.MVC.Demo application to appharbor
    and the same error happens when trying to login...
    It can be checked through this link: http://extnetmvcdemo.apphb.com
  5. #5
    Which IIS do you use on the server? If IIS7 then did you set Ext.Net http module and handler in correct section of web.config (system.webServer)
    See the following README file (III. SAMPLE WEB.CONFIG)
    https://examples1.ext.net/#/Getting_...uments/README/
  6. #6
    I am using IIS Express 7.5
    My web.config file looks like this:

    <?xml version="1.0" encoding="utf-8"?>
    <!-- 
        Note: As an alternative to hand editing this file you can use the 
        web admin tool to configure settings for your application. Use
        the Website->Asp.Net Configuration option in Visual Studio.
        A full list of settings and comments can be found in 
        machine.config.comments usually located in 
        \Windows\Microsoft.Net\Framework\v2.x\Config 
    -->
    <configuration>
      <configSections>
        <section name="extnet" type="Ext.Net.GlobalConfig" requirePermission="false" />
      </configSections>
      <extnet idMode="Explicit" initScriptMode="Linked" scriptMode="Debug" theme="Default" />
      <connectionStrings>
        <add name="ApplicationServices" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
        <add name="PortalContratosMicrosoftConnectionString"
                connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=PortalContratosMicrosoft;Integrated Security=True"
                providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.web>
        <!-- 
                Globalization Settings.
        -->
        <globalization culture="pt-BR" uiCulture="pt-BR" />
        <!-- 
                Set compilation debug="true" to insert debugging 
                symbols into the compiled page. Because this 
                affects performance, set this value to true only 
                during development.
        -->
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
            <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          </assemblies>
        </compilation>
        <!--
                The <authentication> section enables configuration 
                of the security authentication mode used by 
                ASP.NET to identify an incoming user. 
        -->
        <authorization>
          <deny users="?" />
        </authorization>
        <authentication mode="Forms">
          <forms loginUrl="~/Account/Login/" />
        </authentication>
        <membership>
          <providers>
            <clear />
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" />
          </providers>
        </membership>
        <profile>
          <providers>
            <clear />
            <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ApplicationServices" applicationName="/" />
          </providers>
        </profile>
        <roleManager enabled="false">
          <providers>
            <clear />
            <add connectionStringName="ApplicationServices" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/" name="AspNetSqlRoleProvider" />
          </providers>
        </roleManager>
        <!--
                The <customErrors> section enables configuration 
                of what to do if/when an unhandled error occurs 
                during the execution of a request. Specifically, 
                it enables developers to configure html error pages 
                to be displayed in place of a error stack trace.
    
        
        -->
        <customErrors mode="Off" />
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          </controls>
          <namespaces>
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Linq" />
            <add namespace="System.Collections.Generic" />
          </namespaces>
        </pages>
        <httpHandlers>
          <add path="*.mvc" verb="*" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
          <add path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" validate="false" />
          <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="true" />
        </httpHandlers>
        <httpModules>
          <add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />
        </httpModules>
      </system.web>
      <!-- 
            The system.webServer section is required for running ASP.NET AJAX under Internet
            Information Services 7.0.  It is not necessary for previous version of IIS.
      -->
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
          <add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" preCondition="managedHandler" />
        </modules>
        <handlers>
          <remove name="MvcHttpHandler" />
          <remove name="UrlRoutingHandler" />
          <add name="ExtNetHandler" path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" />
          <add name="WebResourceHandler" path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" />
          <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
          <add name="DirectRequestHandler" verb="*" path="*/ext.axd" preCondition="integratedMode" type="Ext.Net.ResourceHandler" />
        </handlers>
      </system.webServer>
    </configuration>
    I based it on the one from the ext.net mvc demo.
  7. #7
    Is the server 64-bit?
    try to switch application pool in IIS to classic pipeline mode

Similar Threads

  1. [CLOSED] Menu.ToConfig() fails in a service
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 13, 2012, 9:29 PM
  2. [CLOSED] DirectMethod fails on IIS Default documents
    By anup in forum 1.x Legacy Premium Help
    Replies: 23
    Last Post: Nov 15, 2011, 4:04 PM
  3. Ext.net.DirectMethod.request MASK
    By sipo in forum 1.x Help
    Replies: 5
    Last Post: May 07, 2010, 5:30 AM
  4. Ext.net.DirectMethod.request PARAMS
    By sipo in forum 1.x Help
    Replies: 0
    Last Post: Apr 15, 2010, 5:06 AM
  5. Populate TreePanel from WCF Service Example Request
    By SunnySingh in forum 1.x Help
    Replies: 0
    Last Post: Mar 29, 2010, 6:19 PM

Tags for this Thread

Posting Permissions