Dear Friends,
I just started digging into Yet another forum. I have come across following scenario. I would appreciate if anyone can help me towards the right approach.
I have 2 sites and Both of them are installed in different web server and are running successfully with their own user management and login mechanism.
This is created using MVC3 and has its own authentication mechanism with SQL server database
Login==> Login mechanism leveraging Entity framework with simple DB call to validate user’s credential and creating forms authentication cookie instead.
User Registration==> Simple Db call with Entity framework to create a user in database.

Note: No where I am using ASP.Net membership provider.
Installed the latest version from and configured. As per my knowledge it leverages “yafmembership provider” for authentication and user management.

My Requirement==>
1. I would like to have a single system for authentication and user management. Currently above 2 sites have their own user management and data persistence mechanisim.
2. If user already logged-in into then he would automatically logged- in into and vise versa for logged-out.
3. User registration, profile update , login will be done from common page for both the site.
4. I would like to maintain single database for user management for both the system

I would think this is a common and typical request, as I just started using YAF and already want this! Anyone?
The most simple way would be to rewrite code to use YAF providers.
Any code samples on how to do this? Any walkthroughs for that?
Someone must have done this?
I'm still working on this - but to help move this topic along, I'll post what progress I have made so far.

(1) edit web.config and set the default loginUrl to your website login page (e.g. Login.aspx)
<authentication mode="Forms">
  <forms name=".YAFNET_Authentication" loginUrl="~/Login.aspx" protection="All" timeout="43200" cookieless="UseCookies"/>

(2) create a default login page (e.g. Login.aspx) and use the standard ASP.NET asp:Login control
<asp:Login ID="usrLogin" runat="server" BackColor="#F7F7DE" BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt">
    <TitleTextStyle BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" />

(3) in your Page_Load method for any page that requires authenticated users, redirect the request to your new Login.aspx page. This login page will log the user into the entire site including the YAF forum.
// check for authentication
if (!Request.IsAuthenticated)

At this stage, the changes above work to authenticate users. I'm still working on further integration using the YAF controls (pages/login.ascx) - which isn't working for me yet.


Following up from my previous post - to integrate YAF into an existing site and share the YAF authentication and membership providers, you will also need to create a new account page so new users don't have to navigate into the forum to create an account. To do this, create a new page such as NewAccount.aspx and drag and drop the ASP:CreateUserWizard control into your new page (standard ASP control).

Using the CreateUserWizard, add an OnCreatedUser event. This event is where you will store the created user default role. The default role for YAF members is "Registered" and the administration role is called "Administrators". If you don't assign a role to your new user accounts, YAF will respond with an error when you try to use that account.

protected void wizardCreateUser_CreatedUser(object sender, EventArgs e)
    String UserName = wizardCreateUser.UserName;
    if ((UserName != String.Empty) && (UserName.Length > 0))
        Roles.AddUserToRole(wizardCreateUser.UserName, "Registered");

Next, you'll want to create an OnContinueButtonClick event. Using this event, you'll redirect the user to an appropriate page such as the homepage.

protected void wizardCreateUser_ContinueButtonClick(object sender, EventArgs e)

Note that the asp CreateUserWizard handles everything else using the providers you have defined in your web.conf file. For integration, you'll be using the YAF providers already discussed in my previous post.

Hope this helps.

Follow up on YAF membership roles - in your aspx code for non-forum pages, you can use the asp:LoginView control to filter content based on the YAF member role; for example, content for "Registered" members versus content for "Administrators" members.

<asp:LoginView ID="pageLoginView" runat="server">
		<asp:RoleGroup Roles="Registered">
				<!-- Content for YAF Registered members (default role) -->
				<p>I AM A MEMBER</p>
		<asp:RoleGroup Roles="Administrators">
				<!-- Content for YAF Administrators members (admin role) -->

In the C# code behind, to find controls that you've placed in these RoleGroup containers, you'll need to using the asp:LoginView FindControl() method. Otherwise your code will not compile. The code below is an example of how to access a control using C#. The xml above doesn't have any controls in the RoleGroup containers.

TextBox myText= pageLoginView.FindControl("MyTextBoxID") as TextBox;

any one completed this recently can share their experience next steps
I'm also just getting to grips with YAF, as we've recently started using it as a staff forum. It'd be great if we could have our staff log in to our existing aspx portal page and have the system create a yaf login for them. In my case, the forum is a sub-folder application of the main portal.

If anyone's done this and has a simplified version that an amateur coder could use, I'm all ears, and potentially buying the beers.
It is possible. What authentication system are you using?
Originally Posted by: tha_watcha 

It is possible. What authentication system are you using?

Our login page to our roster page queries the db, if the user and pw match, it creates a session variable with the user name (same UN we use on the person's forum login).
Originally Posted by: paultg 

Originally Posted by: tha_watcha 

It is possible. What authentication system are you using?

Our login page to our roster page queries the db, if the user and pw match, it creates a session variable with the user name (same UN we use on the person's forum login).

And the DB is a custom db or did you mean the Forum database?


About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved