ASP.NET & .NET Development

Optimizing ASP.NET Performance on a Windows Server 2019 Shared Environment

By the Domain India teamPublished 6 min read
Knowledge base article
Contents (8 sections)

On shared Windows hosting your ASP.NET app shares the server with other sites, so the biggest speed gains come from your own code: fewer database round trips, less work per request, and smaller responses. You can't tune IIS or the server, but you control almost everything that makes a page slow. This guide lists the changes that matter most, in the order to try them.

Key takeaways

Measure first, then fix the slowest thing. Publish in Release mode, cache data that rarely changes with IMemoryCache or output caching, make database calls asynchronous and read-only where possible, and send static files with long cache headers. Expect the first request after an idle period to be slow, because IIS restarts the app. Server-level settings such as application pool limits are managed by Domain India; ASP Enterprise lists a dedicated pool.

1. Measure before you change anything

Guessing wastes time. Find out where a slow page spends its time:

  • Browser developer tools (Network tab) show whether the delay is the server response or the page's images and scripts.
  • The IIS access log in Plesk records the time taken for each request, so you can find the slowest URLs. See How to check Plesk logs.
  • Logging in your code, such as timing each database call, shows which part of a request is slow.

Fix the slowest part first, then measure again.

2. Understand cold starts

IIS stops an idle application after a quiet period and recycles pools from time to time. The next request then waits while your app starts, which can take several seconds for a large .NET app. This is normal on any IIS host.

To reduce it:

  • keep startup light: avoid loading large data sets or warming caches synchronously in Program.cs;
  • publish ASP.NET Core with ReadyToRun (-p:PublishReadyToRun=true -r win-x64), which compiles ahead of time and starts faster, at the cost of a larger upload;
  • store sessions in the database, not in memory, so a recycle doesn't log users out.

Idle and recycling settings are set on the server. The IIS application pools guide explains what you can change.

3. Build and configure for production

  • Publish in Release, never Debug: dotnet publish -c Release.
  • ASP.NET Core: run as Production (the default when nothing is set), so developer pages and detailed errors are off.
  • .NET Framework: set debug to false on the compilation element in web.config. Debug mode turns off compilation optimisations and script bundling, and slows every request.
xml
<system.web>
  <compilation debug="false" targetFramework="4.8" />
</system.web>

Use the targetFramework your project already has.

4. Cache what doesn't change often

Caching is usually the single biggest win on shared hosting.

What to cacheASP.NET Core toolExample
Data used on many pagesIMemoryCacheMenu items, settings, product categories
Whole responsesOutput caching middlewarePublic pages that are the same for every visitor
Static filesCache-Control headersCSS, JavaScript, images, fonts

Keep cache lifetimes short enough that content stays correct, and remember the in-memory cache empties when the app restarts. Distributed caches such as Redis are not listed on the shared Windows plans.

5. Make database access efficient

Slow pages are most often slow queries.

  • Use async calls (ToListAsync, FirstOrDefaultAsync). Blocking calls tie up worker threads while the database answers.
  • Read-only queries: add AsNoTracking() in Entity Framework Core when you won't update the results.
  • Fetch only what you need: Select the columns a page uses, and page long lists with Skip and Take.
  • Avoid N+1 queries: load related data with Include, or one well-shaped query, instead of a query per row.
  • Add indexes for columns you filter or sort on often.

6. Send static files efficiently

In ASP.NET Core, static files are served by your app from wwwroot, so set cache headers there:

csharp
app.UseStaticFiles(new StaticFileOptions
{
    OnPrepareResponse = ctx =>
        ctx.Context.Response.Headers.CacheControl = "public,max-age=604800"
});

Add a version string to file names or URLs (the asp-append-version tag helper does this) so browsers fetch new files after a release. For .NET Framework sites, the clientCache setting under staticContent in web.config does the same job, where the server allows it; if a web.config change causes a 500.19 error, remove it.

7. Make pages lighter

  • Compress and resize images before uploading; serve modern formats such as WebP.
  • Bundle and minify CSS and JavaScript as part of your build.
  • A CDN in front of your site can serve static files from locations near your visitors, with the domain's DNS pointed through the CDN.

8. Know the limits of shared hosting

You can't restart IIS, change server-wide application pool settings or install server software on shared hosting. If your app still needs more after these fixes, the options are a plan with more headroom, or ASP Enterprise for a dedicated application pool that other sites' traffic can't restart. For sudden traffic peaks, see Handling traffic spikes for ASP.NET sites.

The cards show live prices, excluding 18% GST.

ASP Business
₹328.83/mo + GST
  • 30 GB Storage
  • 150 GB Monthly Bandwidth
  • 5 Websites
  • 50 Email Accounts
See plan details
ASP Enterprise
₹493.70/mo + GST
  • 100 GB Storage
  • Unmetered Bandwidth
  • 15 Websites
  • 100 Email Accounts
See plan details
Why is the first page load of my ASP.NET site slow?

IIS stops idle applications and recycles pools from time to time, so the next request waits while your app starts again. Keep startup code light and consider publishing with ReadyToRun to start faster.

Can I change application pool settings on shared Windows hosting?

Server-wide pool settings such as idle timeout and recycling are managed by Domain India. ASP Enterprise lists a dedicated application pool, which isolates your app from other sites.

Does Domain India Windows hosting offer Redis?

Redis is not listed on the shared Windows hosting plans. Use the in-memory cache and output caching built into ASP.NET Core, and keep shared state in your database.

How do I enable browser caching for static files in ASP.NET Core?

Set a Cache-Control header in the OnPrepareResponse option of UseStaticFiles, and add version strings to file URLs so browsers fetch new files after each release.

Should I use debug or release builds on hosting?

Always Release. Debug builds and debug="true" in web.config are slower and can expose details about your code.

Ready for faster ASP.NET hosting? Compare the Windows hosting plans, or open a ticket with the slow URL and what you have measured. Support is on 24/7 live chat, and tickets get a first response within 15 minutes.

Run your ASP.NET app on Windows hosting

Plesk, IIS and MSSQL on every plan, with a dedicated application pool on ASP Enterprise.

See Windows hosting plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app