简体   繁体   中英

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). 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. Navigating away from this page then clicking on the page_one bread crumb should Server.Transfer to page_two but instead crashes. 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. Any suggestions for fixing this?

UPDATE problem solved. Typo in the href, that's why the app crashed (i know, im a dumbass). also, i was just told the URL doesn't matter anyway and to link to the page directly.

A server.transfer does NOT redirect the client browser. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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