1

I need to authorize users programatically.

I have the authorize attribute around my controller:

  [Authorize]
  public class ProductsController : Controller

In another controller action, I'm invoking a webservice which returns an account number if successful. If not, it will return an error. Basically if the if condition is true I want to authorize user across the rest of the site.

 if (!string.IsNullOrEmpty(response.AccountNumber))
 {
   //Write code to Authorize user to use the rest of the site...
   then redirect to a page on my site.
 }else
 {
  //not authorized,
 }

The users of the site will be admins.

Thanks

1 Answer 1

1

Old question, but since there's nothing but crickets here, I thought I'd redirect anyone coming here to question, which seems to do a decent job covering this topic.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.