c# - Controller function not called when user isn't an administrator -


I have the following code but my controller function is not being called for users who have the role of "admin" is not . Can anyone explain why I am going wrong? To clarify, for users where they are in the "Admin" role, it works fine, not everyone is called the controller's job.

VIEW:

  Function acceptedTerm () {Var Username = '@HTML.ValueFor (m = & gt; m.UserName)'; $ .zax ({type: "post", url: '@ Url.Action ("UpdateUserConnects", "user"), data: JSON.stringify ({userName: userName}), content type: "app / jason; charset Data ("failed") {alert ("unsuccessful");} and {var wnd = $ ("# wndTerms"). Data ("cando wando" ); Wnd.close (); $ .ajax ({type: "post", url: '@ Url.Action ("AcceptTerms", "Account"), Content Type: "Application / Jason; Charset = UTF-8 ", Success: work (data) {window.location.href = data}})}}}}); }  

Controller: [AcceptVerbs (HttpVerbs.Post)] Public String Update Connector (String Username) {Service of Users Service Services Users = New Users Try service (); User user = usersService.GetUserByUsername (userName); If (user! = Null) {user.previously Connected = true; UsersService.UpdateUser (user); }} Hold (exception e) {return "failed"; } Return "Success"; }

It later shows that for anyone:

< P> Controller: Public Class UserController: {{AcceptVerbs (HttpVerbs.Post)] [AllowAnonymous] Public string updateUsername (try username () ({usersService usersService = New UsersService ()); User user = usersService.GetUserByUsername (userName); If (user! = Null) {user.previously Connected = true; UsersService.UpdateUser (user); }} Hold (exception e) {return "failed"; } Return "Success"; }

The issue was at the top of the page [authorized] which allows people with the role of "Admin" to access the functions of the controller by default.

Allow all users to allow a specific function [AllowAnonymous] allows the same function as a feature for that function.

Permission to use other role names [Author (roles = "OtherRoll")]


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -