0

I developed an asp.net mvc/angular website, which works fine on my local machine, however when uploaded to my GoDaddy shared hosting account, it takes FOREVER to create the initial database connection, when a user first tries to log into the site & I don't know how to fix (I know I can always move to a better host, but I'd like to see if there's any coding solutions I can try first & that it's not a problem I'm missing within my code).

Here's my site: whesearchreporting.com

Try logging in with any random login & you'll notice it takes about 15-20 seconds to receive the "Invalid Login" message (note: this will only affect the 1st person to hit the website. It seems once a user attempts a connection, any add'l users who try to access the site, can log in instantly).

Here's my observations so far:

  • This only affects the initial login (i.e. the initial database connection). Once you're in, you can hit anything on the website, or even logout & log back in with no problem.

  • If I log in on Computer A (which will take some time), I can then log in as a different user on Computer B almost instantly.

  • I've read GoDaddy overloads their shared hosting servers, so I'm thinking this is the culprit, but not positive.

And here's some of my code:

Angular code:

 angular.module('dashboardApp', [])
.controller('loginController', function ($scope, $location, $window, LoginService) {
    $scope.IsLoggedIn = false;
    $scope.Message = '';
    $scope.Submitted = false;
    $scope.IsFormValid = false;

    $scope.AccountData = {
        Email: '',
        Password: ''
    };

    //Check is the form valid or not. 
    $scope.$watch('frmLogin.$valid', function (newVal) {            
        $scope.IsFormValid = newVal;
    });

    $scope.Login = function () {
        $scope.loading = true;
        $scope.Submitted = true;
        if ($scope.IsFormValid) {
            LoginService.GetUser($scope.AccountData).then(function (d) {
                if (d.data.Email != null) {
                    $scope.IsLoggedIn = true;
                    $window.location.href = "/Account/Dashboard";
                }
                else {
                    $scope.Message = "Invalid login";
                    $scope.loading = false;
                }
            });
        }
    };
})

.factory('LoginService', function($http) {
    var fac = {};
    fac.GetUser = function (d) {
        return $http({
            url: '/Home/UserLogin',
            method: 'POST',
            data: JSON.stringify(d),
            headers: { 'content-type': 'application/json' }
        });
    };
    return fac;
 });

My HomeController:

public JsonResult UserLogin(Account account)
    {
        _accountService = new AccountService();
        if (_accountService.Login(account) != null)
        {
            //valid login credentials.  Set cookie & return client data
            FormsAuthentication.SetAuthCookie(account.Email, false);
        }
        else
        {
            //invalid login.  Delete client data
            account = null;
        }
        return Json(account);
    }

My AccountRepository (Login method):

public string Login(Account a)
    {
        Account account = _accountRepository.GetAccountByEmail(a.Email);
        a.Password = a.Password.Encrypt(a.Email);

        if (account != null)
        {
            //password matches
            if(account.Password == a.Password)
            {
                return account.Email;
            }
            else
            {
                return null;
            }
        }

        return null;             
    }

And finally, my db connection that grabs the account info:

 private readonly Connection _conn;

 public Account GetAccountByEmail(string email)
 {
        Account account;

        using (MySiteEntities db = _conn.GetContext())
        {
            account = (from c in db.Accounts
                      where c.Email.Equals(email)
                      select c).FirstOrDefault();
        }

        return account;
}

Any idea why this initial connection is so slow & any thoughts on what I can do to improve the performance?

Thanks

1 Answer 1

1

Do you know if GoDaddy is using a Windows Server? Because this sounds like a issue with the IIS, it falls into an "hibernation" state after it isn't used for a while. You can change this setting but you can't turn it off as far as I know.

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

3 Comments

Yeah, it's a shared Windows Server.
So this is what you are looking for: social.msdn.microsoft.com/Forums/en-US/…
It was related to GoDaddy. We switched hosting providers & have no slowdown issues now.

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.