PostAlmostAnything-1364 avatar image
0 Votes"
PostAlmostAnything-1364 asked JackJJun-MSFT commented

Why Doesn't Microsoft's Contoso Crafts Demo Work in the Real World?

Micorsoft suckered me into using ASP.Net Core for my latest website with a demo they call [Contoso Crafts][1] complete with videos where Scott Hanselman keeps claiming to be showing people how easy it is to build an ASP.Net Core web application. Problem, he gets all his data at once and if your app ends up with too much data it stops loading. On top of that he doesn't even use a database, so right there everyone working in the real word cannot copy his design exactly. I am now learning this the hard way because every few hours my app stops loading on pages that need post data which uses a task to get all posts.

Since this is clearly a problem of Microsoft's creation I am asking that a Microsoft staff member respond to this question with an example of how someone could use Contoso Crafts with a database in the real world without getting all data at once. They should ideally create a database with at least 10,000 test rows and build an example of how someone could use ASP.Net Core to build an efficient app in the real world.

I've tried giving my app more time to process stuff by adding sqlServerOptions => sqlServerOptions.CommandTimeout(160).EnableRetryOnFailure()); to my Startup.cs file. I also gave the app more max memory in IIS, but it doesn't even seem to try using the additional resources. I also started caching the results of my get all method so that it only had to run once an hour unless a user add or edits anything.

Sample code is available in a previous post which nobody at Microsoft has answered and the only responses I've gotten at all are vague recommendations not to use ToArray() or to use EnableRetryOnFailure() (see Then I posted something on StackOverflow which has gotten a response which looks really good (see That guy is recommending using somethings called an IQueryable and a ViewModel. Those are both new concepts for me because I was not able to build anything new for about 7 years (2012 - 2019) and when I did get back into the game nobody was using WebForms anymore.

Right now I am wondering how to keep my query form crashing my site in the meantime until I fix it. It seems like giving the app more resources doesn't work because it doesn't bother trying to use the new resources. I am wondering if Microsoft has any limits built into .Net Core which would cause an app to crash instead of using all possible CPU and RAM.

I'm leaving town until tomorrow night and if I don't see an answer from a Microsoft employee that solves my problem when I get back I will go on a tyraid around the internet that will persuade people to never bother using ASP.Net Core as long as PHP exists.

UPDATE: Less than an hour after restarting my app and it won't load. My CPU and RAM are well within limits. Is there a maximum constraint in EF Core or .Net Core which limits the size that a query can be? That is the only explanation I can think of other than there being too many requests and a bottleneck somewhere

Also, is there a way I could use SSMS to speed things up on the database side? Like giving a specific database higher priority or making sure that it uses all available resources?

Here is a new local timeout error

SqlException: Connection Timeout Expired. The timeout period elapsed during the post-login phase. The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=5128; handshake=6505; [Login] initialization=499; authentication=965; [Post-Login] complete=4237;
Win32Exception: The wait operation timed out.

It also seems that increasing the timeout too much causes other application which use other databases on the same server to start timing out so I had to reduce it.

UPDATE: I finally found the paging example I used as a guide from MikesDotNetting in which GetData() gets all the data he is using regardless of how much data there is. Now I'm being told that my GetPosts() is what is causing my app to crash due to there being too much data.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@PostAlmostAnything-1364,sorry for the late response, I think it will be better for you to report the issues in that `GitHub`.

0 Votes 0 ·

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered PostAlmostAnything-1364 commented

its a simple prototype, that probably works up to 100 rows.

this is a common design decision, what to do when the data display is more than trivial. web pages handle from around 50 - 100 rows of data. after that you need to add paging or filtering. google for dozens of paging demos.

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I have paging and filters, but they all use GetPosts() and then they page from there. The problem I have now is that I need to keep it form timing out between now and when I fix the query. I thought I might be able to improve things for now by giving the IIS app pool more RAM and using LazyCache but that seems to make no difference.

0 Votes 0 ·

Also, where does Microsoft say that it is a simple prototype that probably works up to 100 rows. My database has over 1,000 rows in the posts table hence the problem. Since Microsoft did not disclose up front that their demo would not work for anything bigger than a few hundred row they are the ones that should be fixing this not me.

0 Votes 0 ·

Also, the query being slow does not fully explain why it works at first and then after about an hour times out every time. Why doesn't it timeout right away and how do I tell the thing to stop trying to fulfill queries and reset itself when it starts timing out a bunch?

0 Votes 0 ·

This is what I am talking about. 5 hours and not a single Microsoft employee responds even when called out by name. They are not even trying to justify their unjustifiable conduct. Vague advice to Goggle stuff without even suggesting a relevant query is not an answer either.

0 Votes 0 ·