asp.net mvc - How to Redirect to external url from controller? -
asp.net mvc 4 project
how redirect external url http-->https controller? can't type:
var url = @"https://www.someurl.com" return redirect(url);
it doesn't work.
also i've tried this:
var uri = new uribuilder(url) { scheme = uri.urischemehttps }; return redirect(uri.tostring());
well stumbled on same problem: have mvc website running under https , have situations need redirect external url recieve parameter , when url http url - http://www.somethingontheweb.com - straightforward
return redirect("http://www.somethingontheweb.com");
actually not work because after looks redirect https://www.somethingontheweb.com not exist @ usually.
still don't know why works i've found work around: i've resorted meta refresh
so have page: ~/views/shared/doredirect.cshtml , here code:
@{ layout = null; } <!doctype html> <html> <head> <meta http-equiv="refresh" content="0; url=@viewbag.redirecturl" /> <title>redirecting</title> </head> <body> <p>redirecting...</p> </body> </html>
and controller code just
viewbag.redirecturl = url; return view("doredirect");
Comments
Post a Comment