I have a web system that I have created C#
with MVC
and database MySQL
. When I try it from my computer (localhost) I have no problem, but when I try it from a production website where it is hosted, it always takes a while for the first time, what I have to do is press the key F5
, and there it loads the page fine , then if I want to reopen the page, it loads fine.
The problem always occurs when the page is first loaded. I know that the problem is not with the database, because when the top of the page loads, it does not make any calls to the database.
I have deduced to think that the problem may be the library jQuery
that I have in the project or that of Bootstrap
, but I find it difficult, since from my computer it works fine, the other thing that I have come to think that it may be the cache or something to enable cookies from the production server.
Actually, it is quite difficult to detect the cause of the delay problem. If anyone knows anything I would greatly appreciate it.
Just to rule out causes, I have been thinking that one of the causes of my problem could be the InitializeSimpleMembershipAttribute class that I have defined in my project (already in MVC, this class is generated) that is in the filter folder? I modified it, commenting code that I think does not work for me, so that I leave it this way:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public sealed class InitializeSimpleMembershipAttribute : ActionFilterAttribute
{
private static SimpleMembershipInitializer _initializer;
private static object _initializerLock = new object();
private static bool _isInitialized;
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
// Ensure ASP.NET Simple Membership is initialized only once per app start
LazyInitializer.EnsureInitialized(ref _initializer, ref _isInitialized, ref _initializerLock);
}
private class SimpleMembershipInitializer
{
//public SimpleMembershipInitializer()
//{
// Database.SetInitializer<UsersContext>(null);
//}
}
}
This behavior can occur for different reasons. I am going to enumerate a list of things that I checked (since the same thing had happened to me) in order to determine the problem.
web.config
check that the mode is not enableddebug
<compilation debug="false">
Release
Propiedades
, in thePackage/Publish Web
active section , theCheckBox
one that saysExclude generated debug symbols
, with this the files.pdb
that contain the mode symbols are not generateddebug
.Pool
should be enabled asAlways Running
. You can configure this in theIIS Manager
>>Grupo de aplicaciones
>> Right click on yourPool
and then inConfiguración Avanzada
>>Modo de inicio
>>Siempre corriendo
(AlwaysRunning
)I hope that in your case, this information is useful.
You may need to do some configuration in your IIS to enable the "Application Initialization Module",
https://www.iis.net/downloads/microsoft/application-initialization