1

I have two views in my MVC 2 Login and Register

In my Login.aspx i have added

    <td>Click here to <%: Html.ActionLink("[Register]", "Register") %></td>

However I am getting ReturnUrl=%2fViews%2fHome%2fRegister in my address bar redirecting it back to Login.

I referred this Stack Overflow Question and made corresponding changes in my web config but no luck.

But when in my config I changed ,

<authentication mode="Forms" >
  <forms loginUrl="~/Home/Login" timeout="2880" />

to

<authentication mode="Forms" >
  <forms loginUrl="~/Home/Register" timeout="2880" />

It worked.

I haven't changed anything in Global.asax.cs file. How can i navigate to my Register view using Html Action Link ??

Note: I am using MVC 2

Thank you All

Community
  • 1
  • 1
  • I think it have to be `<% Html.ActionLink("Register","Register") %>` – Vinh Nov 07 '13 at 07:11
  • @Vinh No it doesnt work –  Nov 07 '13 at 07:15
  • Hmm, I forgot add : in the code, but I think you know it, don't you. I use MVC 2 too, and I think basically it should work `<%: Html.ActionLink("text", "ActionMethod", "ControllerName")%>` – Vinh Nov 07 '13 at 07:33
  • If then, I think you should check Authorize in register page, controller, it's may cause your problem. If the way you use ActionLink is right, something have to be wrong – Vinh Nov 07 '13 at 07:42

1 Answers1

1

What comes to mind is if you have checked if your register method is without the AuthorizeAttribute? Maybe you've put the AuthorizeAtrtribute on top of the controller or you you've created a BaseController with the attribute, so every controller deriving from it need the user to be authenticated

Vinay Rajput
  • 362
  • 1
  • 4
  • 13
  • 1
    +1 That was my first thought too. Do not set the [Authorize] Attribute over the controller, if you need to access a method without logging in. Instead, just add a attribute on every single method a guest isnt allowed to see. – Jannik Nov 07 '13 at 08:04
  • In MVC2 [allow anonymous] is not working otherwise you need to just decorate the register method with this and your requirement is fulfill – Vinay Rajput Nov 07 '13 at 09:20