Does not redirect to Login Page

Asked

Viewed 330 times

2

To authenticate in my system I am using the attribute [Authorize] I put this code down on Web.Config for when the Code 401 which is related to not authenticating it redirects itself to my login page.

<customErrors defaultRedirect="GenericError.html" mode="RemoteOnly">
<error statusCode="401" redirect="Login/Login"/>

But it is not redirecting or generating error.

  • In fact, if the page returns a 401, it should redirect without needing to. You are using ASP.NET Identity?

  • Thanks for the Suggestion, I used the way below.

1 answer

1


The correct way to perform this redirection to the login view is through the tag authentication in your file Web.config. Below is an example:

<configuration>
  <system.web>
    <authentication mode="Forms">
      <forms loginUrl="/SignIn" />
    </authentication>
  </system.web>
</configuration>

Note that you must define the attribute mode as Forms and then in the attribute loginUrl tag forms you specify the URL of your login view.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.