user registration form issue

I have two controllers sitecontroller and usercontroller inside protected/controllers folder.the register

action is defined inside the usercontroller.php file and this actionregister method renders the register.php view file(containing registration form) found inside protected/views/user/ folder. but when i put index.php?r=user/register in the url, it automatically redirects to index.php?r=site/login which is the login form.given below is the code of actionregister method.

public function actionRegister()


          $model=new User('register');

         // uncomment the following code to enable ajax-based validation


         if(isset($_POST['ajax']) && $_POST['ajax']==='user-register-form')


             echo CActiveForm::validate($model);









                  // form inputs are valid, do something here









what may be the reason for this?

Refer to filters(), if your controller has ‘filters()’ and ‘accessControl’ is set on the filter then you will need to allow non-authenticated users to open register page by updating ‘accessRules()’.

  public function accessRules() {

    return array(


        'allow',  // allow all users to access 'index' and 'view' and 'register' actions.

        'actions'=>array('index','view', 'register'), // <= add register action here