无法在asp.net中重定向页面

无法在asp.net中重定向页面,asp.net,cookies,redirect,Asp.net,Cookies,Redirect,我的asp.net页面上有网格。具有3列超链接的网格。两个链接都工作正常。但一个是不重定向所需的页面。我也尝试了不同的浏览器。但得到了不同的错误:as In Mozilla Firefox :The page isn't redirecting properly description In Mozilla Firefox : Firefox has detected that the server is redirecting the request for this ad

我的asp.net页面上有网格。具有3列超链接的网格。两个链接都工作正常。但一个是不重定向所需的页面。我也尝试了不同的浏览器。但得到了不同的错误:as

 In Mozilla Firefox :The page isn't redirecting properly


     description In Mozilla Firefox :


Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
*   This problem can sometimes be caused by disabling or refusing to accept
      cookies.
 In Google chrome : `This webpage has a redirect loop`



      description In Google chrome : 

The webpage at http://myserver:425/(S(c0kr2xuftxiwhm25cm4vjg45))/mypage.aspx?type=2&userId=8 has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
“因为我在网上尝试了很多解决方案,就像我尝试从浏览器中清除cookies一样,”他补充道

<sessionState 
cookieless="false" // True also tried
timeout="10">
</sessionState>

在web配置文件中,但问题是相同的。我检查了链接是否正确重定向所需页面。我的意思是我检查了我链接的拼写,它是完美的。我还有什么办法来解决这个问题?我应该在哪里犯错

<ItemTemplate>
                    <a href="mypage.aspx?type=2&userId=<%#Eval("userId") %>">Go to my page </a>

                </ItemTemplate>

尝试向链接标记添加runat=“Server”属性,如下所示:

<ItemTemplate>
                    <a runat="Server" ID="linkID" href="mypage.aspx?type=2&userId=<%#Eval("userId") %>">Go to my page </a>

                </ItemTemplate>

最明显的检查位置是
mypage.aspx
mypage.aspx.cs
中的重定向(请参见paolo的评论)。问题不是来自网格的链接,这只是一个链接


本例中发生的情况是,您到达
mypage.aspx
,被重定向到
mypage.aspx
,在那里您被重定向到
mypage.aspx
,等等。

如果查询字符串中有一个字段,您也可以尝试此操作。在您的例子中,您有userid

<asp:HyperLinkField HeaderText="Your Header" 
 DataNavigateUrlFields="userId" 
  DataTextField="Your Data Field to Display" 
 HeaderStyle-HorizontalAlign="Center"
  DataNavigateUrlFormatString="mypage.aspx?type=2&userId={0}" 
 ItemStyle-Width="35%"  
 ItemStyle-HorizontalAlign="Left" 
   />

如果有多个

1) DataNavigateUrlFields=“用户ID、员工ID、部门ID”

2) DataNavigateUrlFormatString=“mypage.aspx?type=2&userId={0}&employeeId={1}&deptid={2}”


1和2的顺序必须相同。

是否在任何地方检查,是否重定向相同的页面?我认为您需要彻底检查每个条件,您必须使用相同的参数或不同的参数重定向相同的页面。

您可以显示网格的相关代码吗?它非常庞大,但是…看到一段代码。您是否尝试过此解决方案“清除此站点的cookie或允许第三方cookie可能会解决此问题”在chrome错误中提到。谢谢Furqan。我只想清除所有的饼干。但自从我第一次在浏览器中运行以来,尽管我遇到了同样的问题。我从另一个终端查看,这个网站以前从未打开过。所以这个网站当然不应该有任何cookie。我想我一定是我的网络问题。但不幸的是,无法解决它是网格本身(在您发布的代码片段中)没有进行重定向。您有一个到mypage.aspx的普通链接。问题似乎出在mypage.aspx本身。尝试在mypage.aspx.cs中查找response.redirect。是的,我还尝试在mypage.aspx的页面加载事件上设置断点。但在页面加载事件发生之前,它出现了这个错误。我发现了一些东西,我认为我的页面不接受querystring值。如果我只尝试mypage.aspx或mypage.aspx?type=Not mypage.aspx?type=2,它就正常工作了,我的意思是正确重定向。但是为什么它不接受任何查询字符串值呢?我猜这是路由问题吗?当您直接转到
mypage.aspx
时会发生什么?或者
mypage.aspx?type=2
。不使用网格中的链接。我可以通过以下方式直接访问页面:mypage.aspx。但当然,不获取需要类型和用户id的值。但是通过mypage.aspx?type=2,它显示了我在问题中解释的确切错误。第二个选项(mypage.aspx?type=2)不是重定向到页面,因此无法进入页面加载事件。您的最后一句话是什么意思?您还可以向我们展示
mypage.aspx
Page\u Load
方法吗?我还是觉得有点不对劲,就是说由于使用Eval()导致服务器标签格式不正确。你是对的,当页面加载失败时,我正在重定向同一页面。通过使用Response.Redirect(Request.Url.PathAndQuery);谢谢