简体   繁体   中英

Asp.net Url loses page path on postback

Background: We are redoing our website and trying to modernize it. We were initially experimenting with AngularJS but dropped it due to some of our users being on unsupported browsers. We ended up just doing VB webforms and updating the design and functionality of our site.

I was having an issue with buttons or items that cause a postback. When the page tries to postback it hits to the path but loses everything between the hostname and the last "/"

For example I have a login page set up in the location /Secure/Account/Login.aspx

I have a route as well that directs from /Secure/Account/Login.

So when you visit the page you are at: www.website.com/Secure/Accounts/Login

When I click the login button though, instead of posting back, I am directed to: www.website.com/Login which doesn't exist so I get an error.

This occurs if I navigate to the page instead of using the route as well. So if I am at www.website.com/Secure/Accounts/Login.aspx and click the button, I end up on www.website.com/Login.aspx with an error.

This doesn't affect pages in the root directory as long as they do not use routing attributes. We have some pages that use routing attributes that have the same issue though.

We have page /Category.aspx in the root directory with the route /Category/{Attribute1}/{Attribute2}/ configured for the page.

If I am on the page www.website.com/Category/Attribute1/Attribute2 when I click on a button that posts back, I end up at www.website.com/Attribute2 with an error.

The issue ended up being a really small piece of code from when we were working with Angular

On our master page .aspx we had included the line:

<base href="/">

Removing this line, which we didn't even need anymore fixed the issue.

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