Why are my applications very slow?

I am creating an asp.net application (one of many that I have done).
But this is the first time that I have encountered this particular problem.

When I click the button on the page for the first time (so the application is already loaded), it is very slow.

After the first click of the button, all other calls on this page go very quickly (as it should be).

I opened the sql profiler and charles (http debugger) to see what was happening, and the funny part: the page itself is slow, requests that are being executed are + - 50 ms in total to execute, but it takes 18 seconds to initiate a call to the database.

So .net code takes a very long time before it runs its sql code. I really do not understand. Hope someone can help me.

This is how my application layer runs:

Master page → page → usercontrol button (inside the repeater) →.

The button simply executes the service level, which will access the repository level, which will start the call to the database.

Here is the magazine I received.

this is my application structure:

UserService -> UserRepository: RepositoryBase -> dataAccess. The code:

public User GetByEmailAndPassword(string email, string password)
        {
            _log.Info("UserRepository.GetByEmailAndPassword - Start");
            this.Test();
            User result = null;

            List<DbParam> parameters = new List<DbParam>();
            parameters.Add(new DbParam("@Email", email, DbType.String));
            parameters.Add(new DbParam("@Password", password, DbType.String));

            _log.Info("UserRepository.GetByEmailAndPassword - Entering reader");
            var reader = ExecuteReader("User_GetByEmailAndPassword", parameters);
            if (reader.Read())
            {
                result = _entityFactory.ConvertToModel(reader);
            }

            reader.Close();

            _log.Info("UserRepository.GetByEmailAndPassword - End");

            return result;
        }

Repository Base:

public abstract class RepositoryBase<T>
        where T : IEntity
    {
        private static ILog _log = LogManager.GetLogger(typeof(RepositoryBase<T>));
        protected IEntityFactory<T> _entityFactory;

        protected RepositoryBase()
        {
            _log.Info("Constructor");
            _entityFactory = EntityFactoryBuilder.BuildFactory<T>();
        }

        protected IDataReader ExecuteReader(string storedProc, List<DbParam> parameters)
        {
            _log.Info("ExecuteReader - Start");

            _log.Info("Open connection");
            var db = DatabaseFactory.CreateDatabase();

            _log.Info("Open command");
            var dbCommand = db.GetStoredProcCommand(storedProc);

            foreach (DbParam param in parameters)
            {
                db.AddInParameter(dbCommand, param.Name, param.Type, param.Value);
            }

            _log.Info("Execute command");
            var reader = db.ExecuteReader(dbCommand);

            _log.Info("ExecuteReader - End");

            return reader;
        }
    }

Logs show that it takes 14 seconds for this feature to enter .

var reader = ExecuteReader("User_GetByEmailAndPassword", parameters);

IT DOES NOT FULFILL IT, BUT ONLY INTRODUCING FUNCTIONS.

I am amazed. I really don't understand why a function call in the base class lasts a long time.

I could add some registration information, but it just shows what I'm saying here.

, ?
.

Cheers, .

+3
5

. , , -, . , - ( , ), . , , ...

+2

, - , GET, , (.. -) .

, , ?

, ?

0

, CLR (, , ) DLL , , .

, , CLR, .

http://msdn.microsoft.com/en-us/library/ff647787.aspx, Kinda , .

0

Page_Init LoginLinkButton_Click - - Page_Init, - - ( dll?), page_init,

0

Source: https://habr.com/ru/post/1761057/


All Articles