I need to display the link “Add as User” in my view only when the username is not in the database. I have a method called UsernameExists in my SQL data access layer that I would like to use in the AccountController. How would I go about doing that? The logic should be on the server side, and the link shown on the view.
Share
You can call the UsernameExists method from your controller and add the result to the ViewBag. In your view check the ViewBag and if the bool is true (the username already exists) then don’t display the “Add as User” else display it.
Example-
Controller:
View: