Do not redirect to Login Page

2

In order to authenticate on my system I am using the [Authorize] attribute I placed this code below in Web.Config in> that is related to non-authentication 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.

    
asked by anonymous 18.11.2015 / 13:35

1 answer

2

The correct way to accomplish this redirect to the login view is through the authentication tag in your Web.config file. Here is an example:

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

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

    
18.11.2015 / 13:43