简体   繁体   English

ASP.NET/C#-HTML锚不会Server.Transfer我的页面

[英]ASP.NET/C# - HTML anchor won't Server.Transfer my page

I have a page (page_one) that when loads does a Server.Transfer to a different URL (page_two). 我有一个页面(page_one),当加载一个Server.Transfer到另一个URL(page_two)时。 When page_two loads it adds a bread crumb to the top of the page with an HTML anchor with it's href pointing to page_one, thinking page_two will load by clicking this link. 当page_two加载时,它会在页面顶部添加一个面包屑,并带有一个HTML锚,其href指向page_one,认为page_two将通过单击此链接加载。 Navigating away from this page then clicking on the page_one bread crumb should Server.Transfer to page_two but instead crashes. 离开该页面,然后单击page_one面包屑,应将Server.Transfer转移到page_two,但崩溃。 I fixed that problem by pointing the bread crumb href to page_two, but now clicking on this bread crumb changes my URL to page_two when I want it to read page_one. 我通过将面包屑href指向page_two来解决了该问题,但是现在,当我希望它读取page_one时,单击此面包屑会将URL更改为page_two。 Any suggestions for fixing this? 有什么建议来解决这个问题

UPDATE problem solved. 更新问题已解决。 Typo in the href, that's why the app crashed (i know, im a dumbass). 在href中的错误,这就是应用程序崩溃的原因(我知道,我是一个笨蛋)。 also, i was just told the URL doesn't matter anyway and to link to the page directly. 另外,我只是被告知URL没关系,可以直接链接到页面。

A server.transfer does NOT redirect the client browser. server.transfer不会重定向客户端浏览器。 All it does is internally execute a different page. 它所做的只是在内部执行不同的页面。 The browser will still think it's on the original page. 浏览器仍然认为它在原始页面上。

So, if you need the browser URL to change you'll have to do a Response.Redirect instead of a transfer, or, as antonlavey suggests, just let the link be a regular link and not cause a postback. 因此,如果您需要更改浏览器URL,则必须执行Response.Redirect而不是传输,或者,正如antonlavey建议的那样,只需将链接作为常规链接而不会导致回发。

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

相关问题 在asp.net中使用Server.Transfer添加URL变量 - Add URL variables with Server.Transfer in asp.net 在asp.net中的server.transfer之后,验证不起作用 - Validations not working after server.transfer in asp.net ASP.NET HttpModules和Server.Transfer / Server.TransferRequest / RewritePath问题 - ASP.NET HttpModules & Server.Transfer / Server.TransferRequest / RewritePath problems 如何在Asp.Net中的Server.Transfer之前设置响应头? - How to set Response Header before Server.Transfer in Asp.Net? 在ASP.NET中在Server.Transfer之后使用依赖项注入BuildUp - Use dependency injection BuildUp after Server.Transfer in ASP.NET ASP.net C#使超链接指向页面锚点 - ASP.net c# make hyperlink point to page anchor Server.Transfer,Response.Redirect和ApplicationInstance.CompleteRequest在ASP.Net中可以解决 - Server.Transfer, Response.Redirect, and ApplicationInstance.CompleteRequest work around in ASP.Net 使用Server.Transfer时是否再次执行整个Asp.Net生命周期? - When Using Server.Transfer is the entire Asp.Net life-cycle executed again? C#ASP.NET注册页面将不再更新数据库 - C# ASP.NET Registration page won't update database anymore 为什么我的Razor,ASP.NET,C#HTTPRequests不会返回响应的主体? - Why won't my Razor, ASP.NET, C# HTTPRequests return the body of the Response?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM