[英]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.