如何使用RedirectToAction当我设置的协议? [英] How do I set the protocol when using RedirectToAction?
问题描述
我的目标所需要的行动HTTPS。我已经有一个适当的过滤器,重定向到HTTPS如果请求通过http进来,但我会preFER通过HTTPS从一开始就发送请求。
The action I target needs https. I already have a filter in place that redirects to https if a request comes in via http, but I would prefer to send the request via https right from the start.
修改
有来自达林答案(现在更新到别的东西),他问我为什么反正调用由HTTP这个第一次行动。他有过好点,我刚刚更新了几个环节。这是为了解决我的问题最简单,最安全的方式。
There was an answer from Darin (updated now to something else ) where he asked why I call this first action by http anyway. He had a good point there and I just updated a couple of links. This was the easiest and securest way to fix my problem.
在我找评估çağdaş答案,我将以此为正确的答案,因为我想对另一些人的利益,多数民众赞成的时间(......包括我的未来)
Once I find the time to evaluate çağdaş answer I will use this as the correct answer, because I guess thats of interest for some other people (...including me in the future)
推荐答案
我不知道,如果你必须使用 RedirectToAction
但有一个 UrlHelper
和控制器的重定向
方法,你可以这样做:
I don't know if you must use RedirectToAction
but with a UrlHelper
and the controller's Redirect
method you can do this :
public ActionResult SomeAction() {
UrlHelper u = new UrlHelper(this.ControllerContext.RequestContext);
return Redirect(u.Action("actionName", "controllerName", null, "https"));
}
这篇关于如何使用RedirectToAction当我设置的协议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!