Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
5.00/5 (1 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,
JavaScript
$(".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:
HTML
<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.
C#
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
Updated 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900