我的帐户控制器上有requireSsl。
它似乎适用于除登录操作之外的所有操作。我相信这是因为登录操作被称为如下所示:
new { controller = "Account", returnUrl = HttpContext.Current.Request.RawUrl }
Account/Login?returnUrl...
Account/Login%3freturnUrl...当更改为https时,第二行将导致错误的请求。
编辑:问题是"?“字符被转换为"%3F“。我也尝试过用iis7中的url rewirte来做同样的事情。那么原因是什么以及如何修复呢?
更新:我确实使用了IIS重写来让HTTPS工作,但不是像上面描述的那样使用MVC。我去掉了enable ssl,完全是在iis中实现的。我仍然想知道为什么它在mvc中不能工作。
发布于 2009-12-09 04:29:32
它不工作是因为你所指出的:字符在不应该被编码的时候被编码,这是一个bug。
原始RequireSslAttribute代码:
UriBuilder builder = new UriBuilder
{
Scheme = "https",
Host = filterContext.HttpContext.Request.Url.Host,
// gets encoded and shouldn't include the ?
Path = filterContext.HttpContext.Request.RawUrl
};
filterContext.Result = new RedirectResult (builder.ToString ());可能应该改为如下所示
UriBuilder builder = new UriBuilder
{
Scheme = "https",
Host = filterContext.HttpContext.Request.Url.Host,
Path = filterContext.HttpContext.Request.Path,
Query = filterContext.HttpContext.Request.QueryString.ToString ()
};
filterContext.Result = new RedirectResult (builder.ToString ());https://stackoverflow.com/questions/1829374
复制相似问题