how to detect when a page is called using ajax in asp.net mvc ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to the Professional ASP.NET MVC 1.0 book, the MVC AJAX library will insert a form field called “X-Requested-With” with a value of “XMLHttpRequest”.
You can then use an extension method in System.Web.Mvc that means you can simply call
Request.IsAjaxRequest()and get a simple true or false saying if this is an AJAX request.