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

2019-07-25 14:05发布

问题:

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>();