tags:

views:

131

answers:

1

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

EDIT: I have website, adn obly one page uses https protocol, after I visited it asp.net mvc url engine begin use https protocol anywhere. I have to redirect from this page using http protocol, but by default mvc generate all using https (actionlinks on page, or redirecttoaction using). sorry for my english =)

+1  A: 

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

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

Mauricio Scheffer
when I used it I got an error System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Maksim Kondratyuk
looks like you need more permissions on your hosting.
Mauricio Scheffer