Click here to Skip to main content
14,118,915 members
Rate this:
 
Please Sign up or sign in to vote.
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Use RedirectToAction[^] to redirect the browser to another action.
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.
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web06 | 2.8.190518.1 | Last Updated 26 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100