none
MVC request posts twice URL RRS feed

  • Question

  • I am new in this forum and I had to takeover an existing web app in  MVC 4 with JSon. sorry, if this issue is too trivial:

    Issue: The Web is sending two POST Request by clicking the 'Save' Button.

    I used Fiddler to monitor the activities. I realized that as soon as the 'Save' button is clicked two POST requests are submitted.

    Below is the js code that triggert the POST requests:

            $('#idrSave').click(function (e) {
                e.preventDefault();
                var frm = $(this).closest('form');
                $.post(frm.attr('action'), frm.serialize(), function (data, status, jqx) {
                    if (data.success) {
                        $('#idrModal').modal('hide');
                        $('#iddModal').modal('show');
                    }
                    else {
                        alert('Error encountered: ' + data.error + '\nPlease notify system administrator.');
                    }
                }, 'json');
            });
    Thank you for your help.


    Monday, August 26, 2013 9:27 PM

Answers

  • Hi kamran35,

    Thank you for posting in the MSDN forum.

    It seems that it is not the VS debugger tool, would you mind letting us know more information about this issue? Are you using the VS debugging tool or creating a web test for a web app or others?

    (a)I’m not very sure whether it is related to the web test, I have met a similar issue in web test, when we record a web test, it will capture the requests, and it will be related to the Redirects, so we could set this property to false.

    (b)If it is related to the web app development, I suggest you could post this issue in http://forums.asp.net where asp.net experts live in, and there you would get dedicated support.  A similar thread about the simliar issue, if possible, you could refer it.

    ASP.NET MVC Action is Called Twice

    Best Regards,


    Jack Zhai[MSFT]
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, August 29, 2013 2:40 AM

All replies

  • Hi kamran35,

    Thank you for posting in the MSDN forum.

    It seems that it is not the VS debugger tool, would you mind letting us know more information about this issue? Are you using the VS debugging tool or creating a web test for a web app or others?

    (a)I’m not very sure whether it is related to the web test, I have met a similar issue in web test, when we record a web test, it will capture the requests, and it will be related to the Redirects, so we could set this property to false.

    (b)If it is related to the web app development, I suggest you could post this issue in http://forums.asp.net where asp.net experts live in, and there you would get dedicated support.  A similar thread about the simliar issue, if possible, you could refer it.

    ASP.NET MVC Action is Called Twice

    Best Regards,


    Jack Zhai[MSFT]
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, August 29, 2013 2:40 AM
  • Thank you Jack for your respond. I will post this in the asp.net forum.

    Best Regards,

    Kamran

    Friday, August 30, 2013 12:36 AM