Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!