简体   繁体   English

加载后,ASP.NET页将调用另一个aspx页

[英]ASP.NET Page calls an additional aspx page after loading

To keep things simple, we have a few aspx pages... 为了简单起见,我们有一些aspx页面...

Page1.aspx - resets Session information. Page1.aspx-重置会话信息。
Page2.aspx - Search form with results and sets Session variables. Page2.aspx-搜索带有结果的表单并设置Session变量。
Page3.aspx, Page4.aspx, Page5.aspx - require Session variables set on Page2.aspx Page3.aspx,Page4.aspx,Page5.aspx-需要在Page2.aspx上设置会话变量

What we're finding is that as Page2.aspx loads and setting the Session variables, Page1.aspx is being called and resetting the Session. 我们发现,当Page2.aspx加载并设置Session变量时,将调用Page1.aspx并重置Session。 However, Page1.aspx shows up in the browser, not Page2.aspx. 但是,Page1.aspx显示在浏览器中,而不是Page2.aspx。 We were only able to find this happening as we stepped through the code and put break points in the Page_Load events for Page1.aspx and Page2.aspx and were surprised to see Page2.aspx being processed as soon as Page1.aspx stopped processing on the server. 当我们单步执行代码并将断点放在Page1.aspx和Page2.aspx的Page_Load事件中时,我们才发现发生了这种情况,并且惊讶地发现Page2.aspx在Page1.aspx停止处理后立即在处理服务器。

Possibly useful info... we do use a Master page and there are links to Page1.aspx in the Master page. 可能有用的信息...我们确实使用母版页,并且母版页中有指向Page1.aspx的链接。 Other than that, I can not find any references to Page1.aspx in the code base. 除此之外,我在代码库中找不到对Page1.aspx的任何引用。

update: 更新:
It may be due to authentication? 可能是由于身份验证? It appears that when I access Page2.aspx, the server is possibly authenticating again on Page1.aspx? 看来当我访问Page2.aspx时,服务器可能正在Page1.aspx上再次进行身份验证? Is that typical? 这是典型的吗?

Thanks for the tip Andrew. 感谢小费安德鲁。

We figured out what was going on... Page1.aspx in the application is really Default.aspx. 我们知道发生了什么...应用程序中的Page1.aspx实际上是Default.aspx。 On Page2.aspx, another developer put a img tag on the page that did not have src property defined. 在Page2.aspx上,另一位开发人员在未定义src属性的页面上放置了一个img标签。 So when Page2.aspx executed, it was looking for an image located at the web site's root level, this then triggered the code on Default.aspx (Page1) and wipe away the session. 因此,当执行Page2.aspx时,它正在寻找位于网站根目录下的映像,然后触发Default.aspx(Page1)上的代码并清除会话。

Overall it looked something like this... 总的来说看起来像这样...

On Page2.aspx 在Page2.aspx

<img src=""> <!-- this ended up triggering a call to Default.aspx, wiping the session -->

Hopefully that helps out someone else. 希望这可以帮助其他人。

Launch Fiddler and run the application normally. 启动Fiddler并正常运行该应用程序。 It will tell you the traffic that is occurring and identify what pages are redirecting to other pages. 它会告诉您正在发生的流量,并确定哪些页面正在重定向到其他页面。 Once you know the path, you can identify why that path exists by investigating the source code. 知道路径后,您可以通过调查源代码来确定该路径存在的原因。

It's possible that your application domain is recycling and thus, all the session variables are lost and you probably have code the redirects the visitor if the session variables are missing, right? 您的应用程序域有可能正在回收,因此所有会话变量都将丢失,如果缺少会话变量,您可能已经编写了重定向访问者的代码,对吗?

If this is the case, as quick fix, you can use the StateServer or store your session variables in Sql Server. 如果是这种情况,作为快速解决方案,您可以使用StateServer或将会话变量存储在Sql Server中。 Your application domain shouldn't be recycling every minute, but it could cause the behavior you see if you're storing sessions "in process", which is the default. 您的应用程序域不应该每分钟都在回收,但是如果您将会话存储在“处理中”,这可能会导致行为,这是默认设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM