none
ASP.Net MVC : Supress redirerct to default page RRS feed

  • Question

  • There is a way to suppress redirect to default page in case that the web api return a status code 200 and response message received is 
    <html><head><title>Object moved</title></head><body><h2>Object moved to <a href="/default.aspx">here</a>.</h2></body></html>{"success":true,"message":""}

    We've implemented a mechanism that popup the login form instead of redirecting to the Login page if the session expired. The session is correctly refreshed
    but the call returns "Object moved to here ..." and the page is refreshed.

    The login authentication is the standard Web forms  one.

    Web Api:

            [System.Web.Http.AllowAnonymous]
            [ValidateAntiForgeryToken]
            public dynamic RefreshSession(LoginModel model)
            {
                Refresh session implementation
                 .........
             }

        returns 200 and "Object moved to here ..." the message above


     Angular call
      return $http({
                        method: "POST",
                        url: service.Urls.RefreshSession,
                        headers: { 'Content-Type': "application/json" },
                        transformResponse: angular.identity,
                        data: data
                    })
                    .then(function(response) {
                        return response.data;
                    });


    We used:  context.Response.SuppressFormsAuthenticationRedirect = true
    but didn't work.
    • Edited by V'DAN Friday, May 5, 2017 2:19 PM
    • Moved by CoolDadTx Friday, May 5, 2017 2:38 PM ASP.NET related
    Friday, May 5, 2017 12:28 PM

Answers