[{"data":1,"prerenderedAt":140},["ShallowReactive",2],{"/2025/11/27-forms-authentication-auto-redirects-to-account-login":3},{"id":4,"title":5,"body":6,"date":131,"description":49,"extension":132,"meta":133,"navigation":134,"path":135,"robots":136,"seo":137,"stem":138,"__hash__":139},"posts/2025/11/27 forms-authentication-auto-redirects-to-Account-Login.md","27 Forms Authentication Auto Redirects To Account Login",{"type":7,"value":8,"toc":128},"minimark",[9,18,25,28,31,33,36,50,61,63,66,79,81,89,97,99,102,111,113,120],[10,11,13],"post-title",{":date":12},"date",[14,15,17],"h1",{"id":16},"forms-authentication-auto-redirects-to-accountlogin","Forms Authentication Auto Redirects to /Account/Login",[19,20,21],"notes",{},[22,23,24],"p",{},"This is a repost from my old blog. First posted in 5/7/2020.",[26,27],"br",{},[22,29,30],{},"We are required to add a different authentication method on our ASP.NET Web Forms app. It is currently configured to use OWIN, so I thought I can just disable the current authentication method and revert to the old web.config forms authentication for testing purposes. Turns out it is harder than I thought.",[26,32],{},[22,34,35],{},"After disabling the current authentication method, I add the common Forms Authentication web.config entry:",[37,38,39],"code-block",{},[40,41,46],"pre",{"className":42,"code":44,"language":45},[43],"language-text","\u003Cauthorization>\n   \u003Cdeny users =\"?\" />\n   \u003Callow users = \"*\" />\n\u003C/authorization>\n\u003Cauthentication mode=\"Forms\">\n   \u003Cforms name=\".ASPXFORMSAUTH\" loginUrl=\"~/login.aspx\" protection=\"All\" path=\"/\" timeout=\"30\" />\n\u003C/authentication>\n","text",[47,48,44],"code",{"__ignoreMap":49},"",[22,51,52,53,60],{},"Then I try to access the protected page and to my surprise I got redirected to ",[47,54,59],{"className":55},[56,57,58],"bg-gray-200","p-2","rounded","/Account/Login?ReturnUrl=",". That is weird and I verified other settings and none seems to be out of place.",[26,62],{},[22,64,65],{},"Searching online, I happened to find the following thread:",[22,67,68],{},[69,70,73],"span",{"className":71},[72],"text-blue-600",[74,75,76],"a",{"href":76,"rel":77},"https://forums.asp.net/t/1847413.aspx?How+is+authentication+mapped+to+Account+Login",[78],"nofollow",[26,80],{},[22,82,83,84,88],{},"Following the instruction, I added the following under ",[47,85,87],{"className":86},[56,57,58],"\u003CappSettings>"," tag in web.config and it redirects properly.",[37,90,91],{},[40,92,95],{"className":93,"code":94,"language":45},[43],"\u003Cadd key=\"loginUrl\" value=\"~/login.aspx\" />\n",[47,96,94],{"__ignoreMap":49},[26,98],{},[22,100,101],{},"Update\n5/8/2020\nAccording to the following article, there is a way to disable the redirect instead of changing the destination.",[22,103,104],{},[69,105,107],{"className":106},[72],[74,108,109],{"href":109,"rel":110},"https://docs.microsoft.com/en-us/aspnet/whitepapers/mvc3-release-notes#0.1__Toc274034230",[78],[26,112],{},[22,114,115,116],{},"To disable the auto redirect, add the following under ",[117,118,119],"app-settings",{}," tag in web.config:",[37,121,122],{},[40,123,126],{"className":124,"code":125,"language":45},[43],"\u003Cadd key=\"enableSimpleMembership\" value=\"false\" />\n\u003Cadd key=\"autoFormsAuthentication\" value=\"false\" />\n",[47,127,125],{"__ignoreMap":49},{"title":49,"searchDepth":129,"depth":129,"links":130},2,[],"2025-11-27T00:00:00.000Z","md",{},true,"/2025/11/27-forms-authentication-auto-redirects-to-account-login",null,{"title":5,"description":49},"2025/11/27 forms-authentication-auto-redirects-to-Account-Login","43V7ZI3fuSUR8ynjkR4OjwG8hyfZPTbg_BlcMdzOX9A",1785167452401]