Action does not execute

1

I am using STS authentication, and given given configuration in web.config I can not make my action (Sign In) perform as it should.

to illustrate follows code:

[AllowAnonymous]
    public class SegurancaController : SecurityController
    {
        public ActionResult Index()
        {
....
        }

        [ValidateInput(false)]
        [HttpPost]
        [ActionName("Index")]
        public ActionResult IndexPost()
        {
....
        }
    }

SecurityController:

[AllowAnonymous]
        public ActionResult SignIn(string issuer)
        {
            var wSFederationAuthenticationModule = FederatedAuthentication.WSFederationAuthenticationModule;
            string str = null;
            if (!base.User.Identity.IsAuthenticated)
            {
                str =
                    new SignInRequestMessage(new Uri(string.IsNullOrEmpty(issuer) ? wSFederationAuthenticationModule.Issuer : issuer),
                        wSFederationAuthenticationModule.Realm, wSFederationAuthenticationModule.Reply).WriteQueryString();
            }
            return new RedirectResult(str ?? wSFederationAuthenticationModule.Reply);
        }

And Web.config

<authentication mode="Forms">
      <forms loginUrl="~/Seguranca" name=".ASPXFORMSAUTH" timeout="2880"  defaultUrl="~/home" />
    </authentication>
    <authorization>
      <deny users="?" />
    </authorization>

NOTE: If the <authorization><deny users="?" /></authorization> tags are commented out I can run the URL normally ... but I lose the check if the user is logged in.

    
asked by anonymous 07.05.2014 / 16:40

1 answer

1

As I could not resolve, I solved the case in another way.

I added a Handler to intercept requests as follows.

public class CustomActionFilter : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            var isAuthenticate = filterContext.HttpContext.User.Identity.IsAuthenticated;
            if (!isAuthenticate && controller != "Seguranca")
                filterContext.Result = new RedirectToRouteResult(
                    new RouteValueDictionary 
                    { 
                        { "controller", "Seguranca" }, 
                        { "action", "Index" } 
                    });
        }
    }
    
26.05.2014 / 16:29