public void Redirect_WithEmptyStringUrl_ThrowsArgException()
 {
     Assert.Throws <ArgumentException>("url", () => TypedResults.Redirect(string.Empty));
 }
 public void Redirect_WithNullStringUrl_ThrowsArgException()
 {
     Assert.Throws <ArgumentException>("url", () => TypedResults.Redirect(default(string)));
 }
Exemple #3
0
 /// <summary>
 /// Redirects to the specified <paramref name="url"/>.
 /// <list type="bullet">
 /// <item>When <paramref name="permanent"/> and <paramref name="preserveMethod"/> are set, sets the <see cref="StatusCodes.Status308PermanentRedirect"/> status code.</item>
 /// <item>When <paramref name="preserveMethod"/> is set, sets the <see cref="StatusCodes.Status307TemporaryRedirect"/> status code.</item>
 /// <item>When <paramref name="permanent"/> is set, sets the <see cref="StatusCodes.Status301MovedPermanently"/> status code.</item>
 /// <item>Otherwise, configures <see cref="StatusCodes.Status302Found"/>.</item>
 /// </list>
 /// </summary>
 /// <param name="url">The URL to redirect to.</param>
 /// <param name="permanent">Specifies whether the redirect should be permanent (301) or temporary (302).</param>
 /// <param name="preserveMethod">If set to true, make the temporary redirect (307) or permanent redirect (308) preserve the initial request method.</param>
 /// <returns>The created <see cref="IResult"/> for the response.</returns>
 public static IResult Redirect(string url, bool permanent = false, bool preserveMethod = false)
 => TypedResults.Redirect(url, permanent, preserveMethod);