-1

I have this method here and at the end of the method, I am looking to redirect the user. I have this code:

[HttpPost]
public HttpResponseMessage Post()
{
    // Post Data to Database

    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Moved);
    response.Headers.Location = new Uri("/airportboard");
    return response;
}

but when I run this code, I get this error:

Invalid URI: The format of the URI could not be determined.

What am I doing wrong?

Carrie Kendall
  • 11,124
  • 5
  • 61
  • 81
James Suske
  • 91
  • 2
  • 13

1 Answers1

0

Here:

new Uri("/airportboard");

There isn't enough information for the Uri class to accurately parse the path you gave it. You should pass something that at least has a protocol and domain in addition to the path, such as:

new Uri("http://example.com/airportboard");

There are several ways to construct this URL without needing to know much.

Cᴏʀʏ
  • 105,112
  • 20
  • 162
  • 194