infinite loop of http redirect in asp.net mvc action filter -


i using asp.net mvc 3 developing web application. have written custom global action filter getting triggered whenever invoking of pages in mvc site.

in filter, checking conditions, if conditions met, redirecting user "unavailable" page. working fine in cases expect one.

it not working on home/index, default route. when first launch application can see home/index in fiddler status code 302 (redirect application/unavailable). browser tries redirect application/unavailable page. surprise can see 302 in fiddler page again home/index. keeps continue till time , getting below error in firefox

"firefox has detected server redirecting request address in way never complete."

i can see there infinite loop of 302 in fiddler. don't know why happening. doing wrong in routing?

my code working other pages of website.

here code:

routes.maproute("application", "application/unavailable", mvc.application.unavailable()); routes.maproute("home", "home/{action}", new {controller = "home"}, new[] {"test.web.controllers"}); routes.maproute("default", "{controller}/{action}", mvc.home.index(), new[] {"test.web.controllers"});     public override void onactionexecuting(actionexecutingcontext filtercontext) { ... ...   if (conditionmet)                 {                     routevaluedictionary redirecttargetdictionary = new routevaluedictionary();                     redirecttargetdictionary.add("area", "");                     redirecttargetdictionary.add("action", "unavailable");                     redirecttargetdictionary.add("controller", "application");                     filtercontext.result = new redirecttorouteresult(redirecttargetdictionary);                 } } 

i managed resolve issue. using form authentication in mvc site. , login url configured home/index. when user redirected home/index application/unavailable, redirected again default page user unauthenticated.

i added location entry in web.config excluding application/unavailable page authentication.

<location path="application/unavailable">         <system.web>             <authorization>                 <allow users="*" />             </authorization>         </system.web>     </location> 

and code working fine home/index page.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -