hamid reza shahshahani
hamid reza shahshahani

Reputation: 126

problem with multiple page routing in WASM

i have a razor page with multiple rounting entry:

@page "/profile"
@page "/profile/user/{UserIdParam}"
@page "/profile/exchange/{ExchangeIdParam}"

when i am going to navigate to this routes is fine and worked,but when i need back to caller page , my routing not working. my back button click code:

protected void NavigateToOverviewUserAndExchange()
 {
  if (UserId !=0)
   {
    NavigationManager.NavigateTo("usermanager");
    return;
   }
  else if (ExchangeId != 0)
   {
    NavigationManager.NavigateTo("exchange");
    return;
   }
 }

page url before back button click is:

http:.../profile/exchange/5

and after click back button, page url is :

http:.../profile/exchange/exchange

If i add a slash to begin of page name , is fine but it reload page from server. another problem in this routing when i click on a link on menu then the page is reloaded from server again! my link code:

 <a href="/usermanager">
  <i class="bi bi-circle"></i><span>Users</span>
 </a>

Upvotes: 1

Views: 208

Answers (1)

hamid reza shahshahani
hamid reza shahshahani

Reputation: 126

I forget to add this tag :

<base href="/" />

to index.html, after i added this tag then my problem was solved

Upvotes: 1

Related Questions