How to make Asp.net recognize a JS form feed as an Ajax request?

It seems that by default, Asp.net does not recognize Ext JS calls getForm().submit()as an ajax request. This causes a problem for me because I am trying to return JsonResultinstead of presenting if the request was made through Ajax.

However, when the following is called

        this.getForm().submit({
            url: url,
            waitMsg: 'Saving Request Details',
            scope: this,
            success: function (form, o) {
                ...
            },

            failure: function (form, o) {
                ...
            }
        });

inside my MV.net action Asp.net, which is called, HttpContext.Request.IsAjaxRequest()returns false.

How can I make Asp.Net correctly recognize the request as an ajax request?

+3
source share
2 answers

Yuo can always add a hidden parameter to you that determines that this request through AJAX

+2
source

"X-Requested-With" "XMLHttpRequest". , , extJS.

X-Requested-With , .

.

+2

Source: https://habr.com/ru/post/1786434/


All Articles