After converting MVC 4 project to MVC 5 get error

More
10 years 1 month ago - 10 years 1 month ago #13696 by Rama
Hello,

After converting MVC 4 project to MVC 5 I am getting an error "this website has redirect loop". In my web.config file I have the following:

Code:
<authentication mode="Forms"> <forms loginUrl="~/Account/Register" timeout="2880" /> </authentication>

When I try to click on any menu item, it tries to redirect to /Account/Register page. This was working fine before the conversion. How do I resolve this?

Thanks.
Last edit: 10 years 1 month ago by Pete.

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago - 10 years 1 month ago #13697 by Pete
Hello Rama,

Are you calling an action from your _Layout.cshtml file? If so, make sure you are returning it as a partial view inside the action.

For example, inside your _Layout.cshtml you may have this call:

Code:
<div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> @{Html.RenderAction("TopMenu", "Menu");} </ul> </div>

Your action result should look like this:
Code:
public ActionResult TopMenu() { // Logic to fetch topMenu here return PartialView("TopMenu", topMenus); }

Note that I am returning "PartialView" in this case, NOT "View". Let me know if this helps.

Also, did you custom code your login system? Typically the redirect should be to "~/Account/Login", not "~/Account/Register".

Lastly, make sure you don't have an [Authorize] tag on the "~/Account/Login" or "~/Account/Register" Actions inside the "Account" Controller. Otherwise you will get a redirect loop.

Pete

DigiOz Webmaster
www.digioz.com
Last edit: 10 years 1 month ago by Pete.

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #13698 by Rama
Hi Pete,
This is an existing MVC 4 app that worked without any issues, but when I converted to MVC 5, it just redirects and menu item to the loginUrl link from web.config. It does not matter where I am calling the page from, it always redirects to the loginUrl link.

Thanks.

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #13699 by Pete
Hello Rama,

Can you zip up the project and send it over to me at support@digioz.com? It would make it easier to troubleshoot.

Thanks
Pete

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

Time to create page: 0.120 seconds
Powered by Kunena Forum