locked
How to return to another MVC view or MVC action from web API controller ? RRS feed

  • Question

  • User-1846805900 posted

    Hi

    i have use web api controller to save data into database throw knocoutjs and it works fine, but i need to redirect to other view after inserting data on database and i can't use return view or redirect to action in web api

    as example i need to redirect to MVC action "Index" on MVC controller "Doctors"

    so please how can i do that ?

            readonly GPSContext db = new GPSContext();
    
            public IHttpActionResult AddLoc(Maps_Pos postoadd)
            {
                if (ModelState.IsValid)
                {
                    // save to database
                    db.Maps_Pos.Add(postoadd);
                    db.SaveChanges();
                    return Ok();
                }
                else
                {
                    return BadRequest(ModelState);
                }
            }
    Thursday, May 21, 2015 10:46 AM

Answers

All replies