Authorized attribute does not work MVC 5

I divided Models into a Specific Project

After that, the default MVC attribute [Authorize] does not work in my application

When I try to enter the application, it does not enter the application and is not redirected to a specific page

+5
asp.net-mvc asp.net-mvc-5
source share
7 answers

You have something like this

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

in your web.config?

+4
source share

Check if you removed the form authorization module. Some of the new templates remove authorization of forms by default. If it has been deleted, comment on this. This will look in your web.config:

 <remove name="FormsAuthentication" /> 

I found this question looking for a very similar error, so I thought it would be nice to post my solution.

+11
source share

For me, this has a very trivial error. I have also been authenticated. Owin Authentication remains a registered user, despite the closure of browsers. I need to express the output with the following code:

 public void IdentitySignout() { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie, DefaultAuthenticationTypes.ExternalCookie); } 
+1
source share

I had the same problem when Authorization did not work. At first I thought it was code. But everything was right - it was built without errors. Then I restarted my dev machine and it started working. He worked for the first time, then he had the same problem that he did not work. Think that it should store the value from the first loop and not clear it. (theory only)

0
source share

I just ran into this problem today and wanted to add my solution for anyone who might run into this error. Nothing else worked for me. I recently made an installer for one of the other projects in this solution, and I had to uncheck the "Build" checkbox in Configuration Manager.

If this is not verified, it was not rebuilt when I added the [Authorize] tag, although I made changes to the cshtml page that were shown. I did not understand this until I set a milestone in my control action and noticed that I had never hit it. I even tried to return null from the controller, and the application still moved to a new page.

So, a short story, make sure you build this project in Configuration Manager, which worked for me.

0
source share

For me, I needed to install the following appSetting

 <add key="owin:AutomaticAppStartup" value="false"/> 

to

 <add key="owin:AutomaticAppStartup" value="true"/> 
0
source share

For me, I just deleted cookies from Google Chrome and it worked.

0
source share

All Articles