Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hello.
On my website I have two login action, the first is used then an user is pushing an button to login, which trigger an jQuery UI Dialog. The second is an normal view, which i use if an user isn't Authorized. But what i liked to do instead, is an user is not Authorized, it opens the Login jquery ui dialog instead of redirection to another view.
 
This is how i currently are opening the dialog,
 $(".openLoginDialog").on("click", function (e) {
    e.preventDefault();
    $("<div></div>")
      .addClass("dialog")
      .attr("id", $(this).attr("data-dialog-id"))
      .appendTo("body")
      .dialog({
        title: $(this).attr("data-dialog-title"),
        create: function (event, ui) {},
        close: function () { $(this).remove() },
        open: function (event, ui) {},
        modal: true,
        position: ['center', 130],
        minWidth: 510,
        resizable: true,
        zIndex: 20000
      })
      .load(this.href);
  });
Because the content in the dialog is an partialView it's called like this:
<div class="items iconlogin highligth-br"><a class="openLoginDialog" data-dialog-id="LoginDialog" data-dialog-title="Login" href="@Url.Action("LogOn", "Authentication", new { returnUrl = Request.Url.ToString() })">Login</a></div>
 
Also to help me controlling the not Authorized, i have overriden this calls.
public override void OnAuthorization(AuthorizationContext filterContext)
    {
      filterContext.Result = new RedirectToRouteResult(new
            RouteValueDictionary(new { controller = "Authentication", action = "AccessDenied" }));
    }
I have not been able to find anybody who has done that. Please help.
Best regard Morten Starck
Posted 7-Feb-13 3:19am
Edited 7-Feb-13 3:22am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 430
1 CHill60 410
2 Sergey Alexandrovich Kryukov 394
3 PIEBALDconsult 245
4 BillWoodruff 220


Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 7 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100