asp.net core 1.0 rc2 postback very slow on first execution

大兔子大兔子 提交于 2019-12-24 06:44:35

问题


I recently upgraded my asp.net 5 application to asp.net core 1.0.

The postbacks are very slow (1 minute+) on the first execution. After the user is authorized, the processor peaks and around 10 GB are loaded into memory.

After that the breakpoint in the postback method is hit and the request is executed. If I execute the same method again, it will be very fast.

If I execute another postback method, same thing happens for the first execution.

Edit: The postback object causes this issue. It only happens if I post back objects created by the entity framework with dependencies to other object.

For Instance:

public class PostbackObject
{ 

public virtual Object1 Object1 {get;set;}
public int Object1ID {get;set;}
}

If I comment out Object1

public class PostbackObject
{ 

//public virtual Object1 Object1 {get;set;}
public int Object1ID {get;set;}
}

I don't have any issues. Instead of 40 seconds, it takes less than 1 sec.

The problem is know and will be fixed in the next version.

Here is a temp workaround:

https://github.com/aspnet/Mvc/issues/4666

For anyone that's interested in trying it out before I've had a change to verify the change in full, here's a preview: https://gist.github.com/rynowak/9488b3b1a6b81876d8b14de72feb0857

To use this, paste that class into your project, and add the following line to your ConfigureServices

services.AddSingleton<IModelBinderFactory, MyModelBinderFactory>();

来源:https://stackoverflow.com/questions/37584125/asp-net-core-1-0-rc2-postback-very-slow-on-first-execution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!