重定向到"ReturnUrl"的请求显示登录页面 [英] Redirect request to 'ReturnUrl' displays Login Page

查看:601
本文介绍了重定向到"ReturnUrl"的请求显示登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在本地测试对网页的简单更改.我正在使用VS 2008和VB.net. 我进入了我想去的页面.但是它需要登录,因此可以正确地带我进入登录页面.我可以使用测试帐户成功登录.然后它将重定向到"ReturnUrl",但显示的页面是登录页面,而不是地址栏中列出的正确值-"ReturnUrl"变量.

I am trying to test simple changes to a web page, locally. I am using VS 2008 and VB.net. I enter the page that I would like to go to. But it needs a login, so it correctly takes me to the login page. I can successfully login using a test account. Then it redirects to the 'ReturnUrl' but the page that is displayed is the login page, not the one listed in the address bar which is the correct value - 'ReturnUrl' variable.

我尝试使用Fiddler2来查看是否有问题,但没有.它显示重定向到正确的页面,URL是我要查看的页面,但浏览器(FireFox)中显示的是Login页面.

I tried using Fiddler2 to see if there are any problems, but there are not. It shows the redirection to the proper page and the URL is the page I want to see but what is displayed in the browser (FireFox) is the Login page.

以下是重定向页面的代码:

Here is the code that redirects the page:

If Request.QueryString("ReturnUrl") = "" Then
    Response.Redirect("profile.aspx")
Else
    Response.Redirect(Request.QueryString("ReturnUrl"))
End If

我检查了ReturnUrl值,它是正确的URL. 没有显示错误,但是显示了登录页面,并且清除了登录页面(profile.aspx)的文本框.窗口中显示的URL是"ReturnUrl".

I checked the ReturnUrl value and it is the correct url. No errors are displayed but the Login page is shown with the text boxes of the Login page (profile.aspx) cleared. The URL shown in the window is the 'ReturnUrl'.

有人知道出什么问题了吗?

Does anybody have an idea of what is going wrong?

推荐答案

对于任何为此问题苦苦挣扎的可怜人来说,这就是对我有用的...

For any poor souls who are struggling with this issue, this is what worked for me...

我正在本地运行.那是关键! 在我的代码中,在.Redirect方法调用之前创建了2个cookie: 代码如下:

I am running this locally. That is the key! In my code, there were 2 cookies created before the .Redirect method call: The code looked like this:

 Dim C As HttpCookie
 C = FormsAuthentication.GetAuthCookie(custID.ToString, False)
 C.Domain = "ourdomain.com"
 Response.AppendCookie(C)

 Dim C2 As System.Web.HttpCookie = New System.Web.HttpCookie("ProfileUsername", P.UserName)
 C2.Domain = "ourdomain.com"
 Response.AppendCookie(C2)

我需要将.Domain更改为".localhost".名称中必须至少有一个点.

I needed to change the .Domain to ".localhost". It MUST have at least one dot in the name.

此外,在web.config文件中的元素身份验证中. 模式"是表格". 表单"的属性为domain =.localhost"

Also, in the web.config file, in the element authentication. The 'mode' is 'Forms'. An attribute of 'Forms' is domain=".localhost"

这使我的测试接受了我的测试成员,并继续进行我需要测试的代码部分.

That got my test to accept my test member and move on to the part of the code that I needed to test.

这篇关于重定向到"ReturnUrl"的请求显示登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆