Post Request with angular doesn't return anything from my Action Method

Yar

I am using Angular to send POST request to save the object in my DB and it works, but after saving information it doesn't return the View() (or Content, string, nothing):

public class HomeController : Controller
{
    private MyDb _db = new MyDb();

    [HttpPost]
    public ActionResult Test(SomeModel personalInformation)
    {
        _db.InfoTables.Add(personalInformation);
        _db.SaveChanges();

        // ??
        return View();
    }
}
Brian Lowry

You can't use return View() if you're doing your POST via ajax/Angular. You'll want to use javascript to manage your ng-view or redirect to a new url on success.

Since this is a normal MVC controller, you can post to it with the $http service, then put your view change code in the success function.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why I am able to override Equals method if my class doesn't inherit from anything?

分類Dev

Angular 2 Firebase Observable to promise doesn't return anything

分類Dev

postgresql trigger with dblink doesn't return anything

分類Dev

ANGULAR : POST request return null

分類Dev

Angular doesn't update my object after http request

分類Dev

Why doesn't mongoose's .find({}) method do anything at all?

分類Dev

Why doesn't anything in my if-else work?

分類Dev

Recursive method doesn't return a value

分類Dev

return res.status() doesn't seem to end my code from running?

分類Dev

In Angular how can I pass the response of my post request as one of the parameters to go into another post request?

分類Dev

Overriding FlaskForm.validate() doesn't let POST request through

分類Dev

State doesn't update properly when making a post request

分類Dev

Sending HTTP POST request via HttpURLConnection in Java doesn't work

分類Dev

PHP: How can I return data as response from $.post request?

分類Dev

How to return the response of Post request from a function in NodeJS?

分類Dev

MVC RedirectToAction Doesn't Work After JSON Post Return

分類Dev

Why method persist of PersistentActor doesn't return a Future?

分類Dev

Why doesn't my async function return any result?

分類Dev

Non XHR (non-AJAX) Post request from Angular

分類Dev

Contains method doesn't seem to work with a point inside my polygon

分類Dev

Why doesn't my Deferred run the error method?

分類Dev

express-validator doesn't do anything

分類Dev

AlamoFire doesn't appear to be doing anything

分類Dev

Array doesn't print anything on executing code

分類Dev

Grunt Smoosher doesn't do anything

分類Dev

PHP SimpleXML doesn't output anything

分類Dev

Collectionview doesn't show anything during runtime

分類Dev

Why doesn't ZIP Compression compress anything?

分類Dev

btrfs filesystem resize doesn't do anything

Related 関連記事

  1. 1

    Why I am able to override Equals method if my class doesn't inherit from anything?

  2. 2

    Angular 2 Firebase Observable to promise doesn't return anything

  3. 3

    postgresql trigger with dblink doesn't return anything

  4. 4

    ANGULAR : POST request return null

  5. 5

    Angular doesn't update my object after http request

  6. 6

    Why doesn't mongoose's .find({}) method do anything at all?

  7. 7

    Why doesn't anything in my if-else work?

  8. 8

    Recursive method doesn't return a value

  9. 9

    return res.status() doesn't seem to end my code from running?

  10. 10

    In Angular how can I pass the response of my post request as one of the parameters to go into another post request?

  11. 11

    Overriding FlaskForm.validate() doesn't let POST request through

  12. 12

    State doesn't update properly when making a post request

  13. 13

    Sending HTTP POST request via HttpURLConnection in Java doesn't work

  14. 14

    PHP: How can I return data as response from $.post request?

  15. 15

    How to return the response of Post request from a function in NodeJS?

  16. 16

    MVC RedirectToAction Doesn't Work After JSON Post Return

  17. 17

    Why method persist of PersistentActor doesn't return a Future?

  18. 18

    Why doesn't my async function return any result?

  19. 19

    Non XHR (non-AJAX) Post request from Angular

  20. 20

    Contains method doesn't seem to work with a point inside my polygon

  21. 21

    Why doesn't my Deferred run the error method?

  22. 22

    express-validator doesn't do anything

  23. 23

    AlamoFire doesn't appear to be doing anything

  24. 24

    Array doesn't print anything on executing code

  25. 25

    Grunt Smoosher doesn't do anything

  26. 26

    PHP SimpleXML doesn't output anything

  27. 27

    Collectionview doesn't show anything during runtime

  28. 28

    Why doesn't ZIP Compression compress anything?

  29. 29

    btrfs filesystem resize doesn't do anything

ホットタグ

アーカイブ