GithubHelp home page GithubHelp logo

johnnyhalife / aspnet.suppressformsredirect Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 2.0 301 KB

Module that prevents ASP.NET Forms Authentication to redirect the user to the login page. This is helpful for AJAX, JSON, and all other of non Web Representation (Views/Pages) type of requests.

C# 100.00%

aspnet.suppressformsredirect's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

aspnet.suppressformsredirect's Issues

Suppress doesn't work using WebApi and DelegatingHandler

I'm passing the suppress redirection key in the header, and using the WebAPI DelegatingHandler to add the header if auth fails.

 protected override Task SendAsync(
            HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var requestAuthTokenList = GetRequestAuthTokens(request);
            if (ValidAuthorization(requestAuthTokenList))
            {                
                return base.SendAsync(request, cancellationToken);
            }            

            return Task.Factory.StartNew(
                () =>
                    {
                        var resp = new HttpResponseMessage(HttpStatusCode.Unauthorized)
                                       {
                                           Content = new StringContent("Authorization failed")
                                       };
                        resp.Headers.Add(SuppressFormsAuthenticationRedirectModule.SuppressFormsHeaderName,"true");
                        return resp;
                    });
        }

However, this does not seem to have any effect and the response payload shows the following error:

Authorization failed
    ....html.....Cannot redirect after HTTP headers have been sent.

@Gissues:{"order":50,"status":"notstarted"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.