Click here to Skip to main content
15,867,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
While I Finishing my job in my main page I have to go to the nest one.
I try to do that from the next page controller lets say `loginController`
While I'm in the main controller I use the following function for this purpose:

Public Sub FlagBtn_Click(ByVal myFlag As String) As ActionResult
            Attributes.envProp._LanguageFlag = myFlag
            Attributes.mvcLogin.Index()
        End Sub

The program goes to the next `loginController` and executes the function there:

<Route("Login")>
       Function Index() As ActionResult
           Return View()
       End Function

Which normally has to change the `url` as well according to the `route file`

routes.MapRoute(
          name:="Default",
          url:="{controller}/{action}/{id}",
          defaults:=New With {.controller = "main", .action = "Index", .id = UrlParameter.Optional}
      )

But that doesn't happen. Instead of that the `url` navigation remains on the `Default` route and of course the next page can't be display.
The question here is how to change the `url` navigation, according to page I choose to go.

What I have tried:

Nothing more than I have already done
Posted
Updated 26-Feb-19 7:14am
v2

1 solution

Use RedirectToAction[^] to redirect the browser to another action.
VB.NET
Public Sub FlagBtn_Click(ByVal myFlag As String) As ActionResult
    Attributes.envProp._LanguageFlag = myFlag
    Return RedirectToAction("Index", "login")
End Sub

NB: The first line of that method looks suspicious. Are you trying to store values in a field between requests? That won't work. You'd need to use session state, or the TempData collection, to persist the data.
 
Share this answer
 
Comments
Lefteris Gkinis 28-Feb-19 5:26am    
Sorry but the value did pass to the property very nice... and my issue is not there
My Issue was on the change page...
But thankfully I solved this with Ajax script...
Thanks any way...
Lefteris Gkinis 7-Mar-19 10:41am    
And one more notice
The `redirectToAction` is not working... not working at all...
May be I don't know how to use the `routes`...
But also I haven't find any detail usage about that.
Any suggestion is welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900