[CLOSED] How to redirect after login

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] How to redirect after login

    Hi,
    Can you tell me how to redirect after login. I'm using ASP.NET MVC. This is my code in Controllers
    [AllowAnonymous]
            public Ext.Net.MVC.AjaxResult ExtLogin()
            {
                var username = HttpContext.Request["username"];
                var password = HttpContext.Request["password"];
                var returnUrl = HttpContext.Request["ReturnUrl"];
                if (WebSecurity.Login(username, password) == WebSecurity.MembershipLoginStatus.Success)
                {
                    string script = "window.location.replace('" + returnUrl + "')";
                    return new Ext.Net.MVC.AjaxResult { Script = script };
                }
                else
                {
                    return new Ext.Net.MVC.AjaxResult { ErrorMessage = "The username or password is incorrect" };
                }
    
            }
    Last edited by Daniil; Jun 21, 2012 at 9:53 PM. Reason: [CLOSED]
  2. #2
    Hi,

    The JavaScript replace method doesn't change a origin string.

    Please use:
    string script = "window.location = 'http://ext.net'";
    return new Ext.Net.MVC.AjaxResult(script);
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    The JavaScript replace method doesn't change a origin string.

    Please use:
    string script = "window.location = 'http://ext.net'";
    return new Ext.Net.MVC.AjaxResult(script);
    I had tried your code. But it doesn't work.
    public Ext.Net.MVC.AjaxResult ExtLogin()
            {
                string script = "window.location ='http://ext.net'";
                return new Ext.Net.MVC.AjaxResult(script);
    
            }
    This is my button used in LoginForm:
    .Buttons(button =>
        
            button.Add(Html.X().Button()
                .ID("btnLogin")
                .Icon(Icon.Accept)
                .Text("Login")
                .DirectEvents(de =>
                    {
                        de.Click.Url = "/Account/ExtLogin/";
                        de.Click.FormID = "loginForm";
                        de.Click.CleanRequest = true;
                        de.Click.Timeout = 60000;
                        de.Click.ExtraParams.Add(new Parameter("ReturnUrl",System.Web.HttpContext.Current.Request["ReturnUrl"]));
                        de.Click.Method = HttpMethod.POST;
                        de.Click.Failure = "Ext.Msg.show({title: 'Login Error',msg: result.errorMessage,buttons: Ext.Msg.OK,icon: Ext.MessageBox.ERROR});";
                        de.Click.EventMask.ShowMask = true;
                        de.Click.EventMask.MinDelay = 500;
                    })
                .OnClientClick("if (!#{username}.validate() || !#{password}.validate()) {Ext.Msg.alert('Error','The Username and Password fields are both required'); return false; }"))
  4. #4
    Quote Originally Posted by UnifyEducation View Post
    But it doesn't work.
    Any error, exception? What does happen? Please provide more details.

    What is the response text of the DirectEvent?
  5. #5
    Quote Originally Posted by Daniil View Post
    Any error, exception? What does happen? Please provide more details.

    What is the response text of the DirectEvent?
    Hi,

    There are no error, no exception. Nothing happens, my page did not reload or redirect to other page.
    I don't know how to find the response text of DirectEvent.
  6. #6
    Quote Originally Posted by UnifyEducation View Post
    I don't know how to find the response text of DirectEvent.
    To inspect requests you can use Developer Tools of IE9 or Chrome, Fiddler, FireBug for FireFox.

    Here is the "guide" screenshot for FireBug.
    http://forums.ext.net/showthread.php...ll=1#post46243
  7. #7
    Quote Originally Posted by Daniil View Post
    To inspect requests you can use Developer Tools of IE9 or Chrome, Fiddler, FireBug for FireFox.

    Here is the "guide" screenshot for FireBug.
    http://forums.ext.net/showthread.php...ll=1#post46243
    Hi,

    The response is
    { }
    Click image for larger version. 

Name:	localhost-51713.png 
Views:	103 
Size:	51.1 KB 
ID:	4382
    I'm using MVC4, here is my code:
    public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.IgnoreRoute("{exclude}/{extnet}/ext.axd");
    
                routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );
    
                routes.MapRoute(
                    name: "Default",
                    url: "{controller}/{action}/{id}",
                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );
            }
        }
    In global.asax
    protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();
    
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
            }
    In web.config
    
        <httpHandlers>
          <add path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" validate="false" />
        </httpHandlers>
        <httpModules>
          <add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />
        </httpModules>
    In Home/Index:
    @using Ext.Net
    @using Ext.Net.MVC
    @{
        Layout = null;
    }
    @Html.X().ResourceManager()
    @(Html.X().Button()
        .ID("btnLogin")
                    .Icon(Icon.Accept)
                    .Text("Login")
                    .DirectEvents(de =>
                    {
                        de.Click.Url = "/Account/ExtLogin/";
                        de.Click.CleanRequest = true;
                        de.Click.Timeout = 60000;
                        de.Click.Method = HttpMethod.POST;
                        de.Click.Failure = "Ext.Msg.show({title: 'Login Error',msg: result.errorMessage,buttons: Ext.Msg.OK,icon: Ext.MessageBox.ERROR});";
                        de.Click.EventMask.ShowMask = true;
                        de.Click.EventMask.MinDelay = 500;
                    }))
    In Account Controller
    [AllowAnonymous]
            public Ext.Net.MVC.AjaxResult ExtLogin()
            {
                string script = "window.location ='http://ext.net'";
                return new Ext.Net.MVC.AjaxResult(script);
            }
  8. #8
    Does the same work with MVC3 on your side?

    What Ext.NET sources do you use?
  9. #9
    Could you check what is the value of
    X.IsAjaxRequest
    within the ExtLogin controller action?
  10. #10
    Quote Originally Posted by Daniil View Post
    Could you check what is the value of
    X.IsAjaxRequest
    within the ExtLogin controller action?
    X.IsAjaxRequest = true;
    Click image for larger version. 

Name:	example.jpg 
Views:	120 
Size:	36.0 KB 
ID:	4384
    I use Ext.NET sources from svn.
Page 1 of 2 12 LastLast

Similar Threads

  1. login & response.redirect
    By svk in forum 1.x Help
    Replies: 2
    Last Post: Jan 17, 2013, 6:10 AM
  2. [CLOSED] about:After login Redirect?
    By wkcode in forum 1.x Help
    Replies: 6
    Last Post: Jan 15, 2013, 5:12 AM
  3. [CLOSED] Differences between X.Redirect and Response.Redirect
    By SouthDeveloper in forum 1.x Premium Help
    Replies: 2
    Last Post: May 10, 2012, 4:29 PM
  4. Problem to Redirect To Login Page
    By aniketyadav7 in forum 1.x Help
    Replies: 6
    Last Post: Feb 23, 2012, 7:29 AM
  5. login problem with Ext Login Control
    By Bruce2010 in forum 1.x Help
    Replies: 1
    Last Post: Nov 30, 2010, 4:35 PM

Tags for this Thread

Posting Permissions