use*_*624 5 django internet-explorer redirect
我有一个使用Django的Facebook应用程序.在我的一个视图中,我使用以下代码来使用户登录.
在IE中,返回HttpResponseRedirect行失败,并显示错误消息"此内容无法在框架中显示...",尽管其他浏览器工作正常.
你有一个想法,为什么IE为HttpResponseRedirect失败?(这是问题是在Windows 7上的IE9上产生的,服务器是使用django-1.3)
def auto_login(request):
username = request.GET['username']
password = request.GET['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
theURL='http://apps.facebook.com/myapp/'
return HttpResponseRedirect(theURL)
else:
return HttpResponse("disabled account")
else:
return HttpResponse("Invalid login")
Run Code Online (Sandbox Code Playgroud)
这可能是两件事,都与浏览器安全模型有关。
选项 1是重定向到另一个域。客户可以决定遵循重定向或拒绝。特别是 HTTP 307 重定向(允许转发 POST 数据)并不总是被客户端接受。
选项 2涉及使用 HTTP 方法 POST url 将资源重定向到使用方法 GET 的另一个资源。
如果当前视图的 HTTP 方法和重定向不同(即针对 /login url 的 HTTP POST 与 facebook/myapp 的 HTTP GET),至少 IE8 会拒绝重定向。我不确定 IE9 中是否对此进行了更改。
有几件事你可以尝试。
一些好的链接:
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
| 归档时间: |
|
| 查看次数: |
992 次 |
| 最近记录: |