SSOLogon from owin cookie middleware. The End() problem


This updates

Note how I add false to such as Response.Redirect(strRedirect, false); Otherwise, the SSOlogon page gets visited multiple times.


using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using System;
using System.Security.Claims;
using System.Web;
using System.Web.UI;


namespace WebApplication2
{
    public partial class _SSOLOGON : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            HttpContext.Current.GetOwinContext().Authentication.SignIn(
                new AuthenticationProperties { IsPersistent = true },
                new ClaimsIdentity(new[] {
                                            new Claim(ClaimsIdentity.DefaultNameClaimType, "peter")
                                          },
                                    CookieAuthenticationDefaults.AuthenticationType)
            );

            var strRedirect = Request["ReturnUrl"];

            if (strRedirect == null)
                Response.Redirect("AccessDenied.aspx", false);

            Response.Redirect(strRedirect, false);
        }
    }
}

Advertisements

About home_pw@msn.com

Computer Programmer who often does network administration with focus on security servers. Very strong in Microsoft Azure cloud!
This entry was posted in coding theory. Bookmark the permalink.