asp.net mvc - Website Slow At Loading The Login Form -
i have asp.net mvc website developing, , deployed on test server client give initial feedback.
i have noticed on live server there considerable delay in loading login form, of around 20-30 seconds. once logged in, system functions fine, , responsive.
if log out, , return login page, once again slow.
it doesn't appear issue apppool spooling up, happens every time on page, not once, , items appear loading.
any suggestions on how debug this?
below basecontroller controllers enherit, plus account login controller.
protected override void executecore() { if (user.identity.isauthenticated) { try { accountdatacontext = new accountdal.datacontext(configurationmanager.appsettings["server"]); // set current user. currentuser = accountdatacontext.users.firstordefault(x => x.email == user.identity.name); accountdatacontext.currentaccount = currentuser.account; viewbag.currentuser = currentuser; viewbag.account = currentuser.account; systemdatacontext = new systemdal.datacontext(configurationmanager.appsettings["server"], currentuser.account.database); // setup account based on users settings viewbag.theme = "default"; // hard coded } catch (exception) { // if previous threw exception, logged in user has been deleted // log them out formsauthentication.signout(); session.abandon(); // clear authentication cookie var cookie = new httpcookie(formsauthentication.formscookiename, ""); cookie.expires = datetime.now.addyears(-1); response.cookies.add(cookie); formsauthentication.redirecttologinpage(); } } base.executecore(); } and accounts controller:
[allowanonymous] public actionresult login(string returnurl) { viewbag.returnurl = returnurl; return view(); } // // post: /account/login [httppost] [allowanonymous] [validateantiforgerytoken] public actionresult login(loginviewmodel model, string returnurl) { if (modelstate.isvalid) { if(accountdatacontext == null) accountdatacontext = new accountdal.datacontext(configurationmanager.appsettings["server"]); var user = accountdatacontext.users.firstordefault(x => x.email == model.username && x.password == model.password); if (user != null) { formsauthentication.setauthcookie(model.username, model.rememberme); return redirecttolocal(returnurl); } else { modelstate.addmodelerror("", "invalid username or password."); } } // if got far, failed, redisplay form return view(model); }
couple of things improve performance:
first , foremost : deploy site in
releasemode if care @ performance. here great article dave ward it.<compilation targetframework="your framework version" debug="false">if not using
webformsview engine (which assume not) jus disable , userazor, take little further, allow chtml filesviewengines.engines.clear(); iviewengine razorengine = new razorviewengine() { fileextensions = new string[] { "cshtml" } }; viewengines.engines.add(razorengine);configure idle time-out settings application pool (iis 7) here's link
edit1:
based on last comment mentioning app running fine in local iis. recommend start focusing on analyzing requests on remote iis , here's link tool can use.
in order trace successful requests (and should in case) set status 200 here's tutorial on well.
Comments
Post a Comment