c# - Redirect to external URI, even if it's not valid -
general info:
i working on asp.net mvc 5 application sends emails , tracks link-clicking within each email. when user follows link, performs query web server query parameters. meanwhile, application saves information click , redirects user initial (target) site.
closer point:
the links in mails may arbitrary (e.g. http://www.google.com, //google.com, www.google.com) or not valid (e.g. ab//cd). application doesn't care string values of urls (even if it's \asdf//sadg:) , paste them directly address bar.
for purpose tried use redirect
, redirectpermanent
methods, , uribuilder
class. redirect
, redirectpermanent
may combine addresses , try redirect local path if url specified without scheme. uribuilder
manages add scheme if needed, throws exceptions when url invalid. javascript location.replace
has same behavior c# redirect
, way.
the issue:
how can redirect arbitrary urls asp.net mvc controller without validations , redirects local paths?
you should able use redirect() method , pass in string. don't think tries validate given uri long pass in string.
tested , "works" (browser receives correct location header):
return redirect("\asdf//sadg:");
if want "manually", perform redirect yourself:
response.addheader("location","whateverurl"); httpcontext.response.statuscode = (int)httpstatuscode.moved; return new contentresult() { content = string.empty };
Comments
Post a Comment