How to set protocol when using RedirectToAction in asp.net MVC?

How can I call RedirectToAction and set http or https in it?

EDIT: I have a website and one page uses the https protocol after I visited it. asp.net mvc url engine started using https protocol anywhere. I have to redirect from this page using http protocol, but by default mvc will generate everything using https (actionlinks on the page or redirect using). sorry for my english =)

+2


source to share


1 answer


Use RequireSslAttribute

(in MVC Futures) with redirect = true to switch from http to https instead of trying to set the protocol in RedirectToAction. It's just more reliable.



If you need to switch from https to http, you can write a similar attribute based on the RequireSslAttribute code .

+1


source







All Articles