Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

137
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda