Verfiy code after login


I want to have verify code utility once a valid username/password has been entered.  So, after users login, a random code will be sent to their email address and then the users have to enter it again in the application to login.  Can I do that with C#?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What you are asking is doable and not that hard but need more information on where is it that you are facing trouble.
- Do you have login feature in place? If so are you using built-in control?
- Are you using membership providers?
- Do you want it on every single login or just when user registers very first time?
perlwhiteAuthor Commented:
1. I have simple login feature in place.
2. I am not using membership providers!( I did not know they could be used, researching on them now)
3. I want to use this for every single login unless they are logging in after more than 30 days.

- You will need to have a fields in your user table e.g. and Code(string)
- When user tries to login i.e. in Login button click, you can create a random string and store it in that "Code" field in the database. Email the user that string and redirect to some page called verifycode.aspx
- Once the user enters the valid code, can clear the Code field in the database, set FormsAuthenctication cookie and redirect user to your landing page.

You requirements are too broad to provide you full code.
Here's a sample though.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.