Hey there,
have you used added a reference to the membership provider in the web.config? Also, you get this error most of the time if you are using ASP.Net MVC. Let us know if you are using that.
How to use Membership Provider[
^] is a great article on how to embed the membership functionality into your website. Furthermore, if you read this article thoroughly, you do not have to check whether the user is authenticated in the code behind. You can do this by adding a web.config for each directory of the website and allow/deny access to users, roles, etc.
Walkthrough: Creating a Web Site with Membership and User Login[
^] << For further reading.
Hope this helps, regards