Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
Redirect from asp.net web api post action doesn't seem to work

As a new comer to ASP.Net looking for workaround on, redirecting to another URL at the end of the HttpResponseMessage POST api.

In reference to Redirect from asp.net web api post action I tried same procedure to redirect. Api returns response to caller but no redirect is happening. The Api call response goes to fail callback on javascript side.

Any suggestion on solving this is greatly appreciated.

Tried calling Post API from Javascript. Always throws error with CORS.

// C# API

[HttpPost] 
[Route("SignInTest")] 
public HttpResponseMessage Post(SignInModel signInModel)
 {
    HttpResponseMessage response = null; 
    EntityResponse<UserAuthenticationDTO> userAuthenticationDTOResponse =         
       _authenticationService.Validate(signInModel.Login, signInModel.Password); 
    if (userAuthenticationDTOResponse.IsSuccess) 
    {
       var response = new HttpResponseMessage(HttpStatusCode.Redirect);
       response.Headers.Location = new Uri("https://sample.com"); // to url that I have to redirect
       return response; // expected https://sample.com to load 
    } 
    response = Request.CreateResponse(HttpStatusCode.InternalServerError,     ErrorCode.AccountVerificationEmailIsNotVerified); 
    return response;
 }

// Javascript Caller
dataContext.singleSignOn.SignInTest(self.validatedObservable).done(function (data)
{
   console.log("data", data);
}).fail(function (error) 
{
   console.log("done with error", error); // Always throws error with CORS for https://sample.com to load .
  
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda