Muhammad Adeel Zahid
Muhammad Adeel Zahid

Reputation: 17794

Preventing Execution on Child and Ajax Requests

we are using asp.net mvc-3 for our application. we populate a property of controller from db on initialize method of controller. i don't want this code to be executed on partial requests and ajax requests. is there some way i can achieve this without directly accessing Request object? Any suggestions in change of approach are also welcome

Upvotes: 0

Views: 101

Answers (1)

Adam Tuliper
Adam Tuliper

Reputation: 30162

Why not use the Request.IsAjaxRequest if its available? If you don't want this property you need to access a header, which is in the request object anyways. The partial request won't hit your controller anyways - only RenderAction will hit your controller. RenderPartial will only hit your view.

Upvotes: 1

Related Questions