Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
OK,

Here's an odd one!

I am returning a view
return
View("Index", clients)

and the resulting Razor page is, in fact the Index page.
HOWEVER,
The URL is retaining the "old" Razor page name ("EditRecord.cshtml") which is causing that page's action to be called when paigng through my grid.

CONTROLLER...
[HttpGet]
        public ActionResult UpdateClient()
        {
            // Perists record chagnes to database
            const string PROCNAME = "UpdateClient";

            try
            {
                int id = Convert.ToInt32(Request["ID"]);
                // Routine (actually stored proc.) will check for the existence of this ID
                //     and update an existing records or create a new.
                //Request.Form["name"].ToString();

                //clientMethods.SaveClient(Convert.ToInt32(collection["ClientGrid.id"].ToString()), collection["Name"], collection["ClientGrid.Email"]);
                clientMethods.UpdateClient(Convert.ToInt32(Request["id"].ToString()), Request["Name"].ToString(), Request["Email"].ToString());
                List<Client> clients = clientMethods.GetClients();
                return View("Index", clients);
            }
            catch (Exception ex)
            {
                ProgLog.Log(ex.Message, PROCNAME, MODNAME);
                return null;
            }
        }




URL:
http://localhost:52545/Client/UpdateClient?ID=1&Name=Stu+Pidasso&Email=stupiddaso%40gmail.com

In the above /Client/UpdateClient are the PREVIOUS SUBMIT.

What gives, you people?

What I have tried:

[HttpPost]
[HttpGet]

Not using form SUBMIT at all and relying on form collection.

I should add that I'm using grid.mvc that grab URL info for pagination. Not always appreciated.
Posted
Updated 21-Aug-18 7:02am
v2

1 solution

OK.
Figured it out.
I am a dumbass!

I just needed to call a return RedirectToAction(original view);
instead of return View("Index", Clients);

from my controller action that calls the savedata() routines.
 
Share this answer
 

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