Thoughts on the Exception Handling Mechanism of roles and users in Asp.net

Source: Internet
Author: User

There are two functions. Let's implement them. How can we handle exceptions?

Roles. addusertorole (user, role); What should I do if the user is already a role?
Roles. removeuserfromrole (user, role); What should I do if user is no longer a role?

In the past, we have encountered such situations. In both cases, we can naturally release them, because the goal has been achieved. Why should we consider the past situation? But in fact, both functions are self-contained functions in Asp.net, and two exceptions are returned respectively.

From the technical implementation point of view, this is redundant, but from the application point of view, the more you think, the more reasonable.

Assume that this is an application system.CodeAfter receiving a command to authorize or unauthorize a user who has been authorized or unauthenticated, it is very likely that there is a problem with the judgment logic, in addition, the authorization information displayed on the view is incorrect. Therefore, an operation link that is not supposed to exist is generated (MVC is used, and the link is the operation ). It is necessary to remind users that the appearance you see is different from the actual situation! Instead of simply solving it technically, otherwise there will be some wrong authorization situations in other places.

 

Click to download the free agile development textbook: Martian agile development manual

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.