开发者

Preventing Execution on Child and Ajax Requests

开发者 https://www.devze.com 2023-03-03 19:22 出处:网络
we are using asp.net mvc-3 for our application. we populate a property of controller from db on initialize method of contro开发者_运维技巧ller. i don\'t want this code to be executed on partial reques

we are using asp.net mvc-3 for our application. we populate a property of controller from db on initialize method of contro开发者_运维技巧ller. 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消