0

I am new to MVC and I don't know how to use authentication and authorization attributes in MVC application, I have used these in asp.net webform application as follows;

<authentication mode="Forms">
      <forms loginUrl="login.aspx" defaultUrl="home.aspx" protection="All" timeout="2880"/>
    </authentication>
    <authorization>
      <deny users="?"/>
    </authorization>

which works fine for me, Now When I use same in MVC application with following changes;

<authentication mode="Forms">
        <forms loginUrl="~/Account/Login" defaultUrl="~/Home/Index" timeout="2880" />
    </authentication>
    <authorization>
        <deny users="?"/>
    </authorization>

also I have used [Authorize] keyword on ActionResult Login(), which is allowing the users access to the website.

but it shows me error as follows;
The requested page cannot be accessed because the related configuration data for the page is invalid.
Please suggest me what amendments or addition should I do to make it working. Thanks in advance.

1
  • you forgot to add <allow users = "*" /> on authorization part, in web.config Commented Dec 12, 2013 at 6:48

1 Answer 1

1

You can go through this Tutorial. It might help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.