- Posts: 2
- Thank you received: 0
After converting MVC 4 project to MVC 5 get error
10 years 7 months ago - 10 years 7 months ago #13696
by Rama
After converting MVC 4 project to MVC 5 get error was created 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:
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.
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 7 months ago by Pete.
Please Log in or Create an account to join the conversation.
10 years 7 months ago - 10 years 7 months ago #13697
by Pete
DigiOz Webmaster
www.digioz.com
Replied by Pete on topic After converting MVC 4 project to MVC 5 get error
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:
Your action result should look like this:
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
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 7 months ago by Pete.
Please Log in or Create an account to join the conversation.
10 years 7 months ago #13698
by Rama
Replied by Rama on topic After converting MVC 4 project to MVC 5 get error
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.
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.
10 years 7 months ago #13699
by Pete
DigiOz Webmaster
www.digioz.com
Replied by Pete on topic Re:After converting MVC 4 project to MVC 5 get error
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
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.122 seconds