Page loading issue in asp.net mvc3 - asp.net

My website has a lot of menus and submenus in its index page and these submenus are loaded from the db.Ajax is used to load the submenus. So its taking a lot of time to load the full page. How will i reduce the loading time.I am using asp.net mvc3 and sql server 2008 database

It's very hard to tell what could be the bottleneck in your solution without actually seeing it, but it sounds that you can benefit greatly by doing caching, in ASP.NET MVC it's quite easy to do, here is another great tutorial on the subject. Oh and remember -> “There are 2 hard problems in computer science: caching, naming, and off-by-1 errors” ;)

There are many things that could be going wrong and causing your application to run slowly.
I’d recommend you turn the trace feature on because that will tell you what may be wrong. As Dimitar Dimitrov already mentioned you can try to cache the query in some way so you don’t have to retrieve it every time.
Another option would be to optimize the query so that it fetches all menus and submenus in one query.
But again, don’t do anything specifically until you’ve profiled your application to see where specifically is the issue.

Related

How to make asp.net web forms application faster?

My last project is a medium size asp.net web forms application. It is built using:
asp.net 3.5
ling to sql dbml --> sql server database (9 tables)
ext.net 1.6 (www.ext.net)
structuremap 2.5.3.0
This time I believed I did my best in terms of architectural design, code and data transfer optimizations. I followed all advice I could to work with the database efficiently through linq to sql and I built layers (model, repository, service, presentation) to separate concerns and lightweight the code in the aspx code behind files.
The problem is: I've installed the application in various web hosting servers with the same pitiful result: the application is struggling to work... pages are loading like in slow motion...
In the past I would say 'OK, I didn't do all I could to speed things up' but in this case I really tried to apply the best practices...
Is there anything else I can do about it? Or is it just asp.net for really small projects only?
thank you.
ASP.NET is fine for building large scale websites. As Brad mentioned, StackExchange sites are built using it, and StackOverflow is a very busy site indeed.
What you need to do first is measure performance; until you do that, you're just guessing at where the problem areas are.
So start with the browser - use a tool such as Firebug, or YSLOW, Google Chrome dev tools, whatever takes your fancy and run your site using the tool enabled. The tools can let you know how long things are taking to process eg requests, how long content is taking to download etc.
YSLOW will also give you some tips on anything it finds as being a bit slow e.g. you're making to many HTTP requests, you should consider minifying your CSS/JS files. You will get a general overview of how the site is performing and where problems could be.
To dig a bit deeper, use a tool like RedGate's ANTS Profiler, use the trial version and measure your website, and server side code, with that tool. There are other tools, though I'm not aware of any free ones.
My first question is that when its slow. Did you try your project in Local area network. Please check first there. If there slow then you need to improve little bit.
This slow performance depends on many things
such as large data load, multiple logic on one page etc.
Please let me know.
Thanks
Basit.

My site is taking a very long time to load, what can I do to investigate the issue?

my site is ASP.NET,C#, .net 4, using Umbraco 4, IIS 7.5 it has been working great for months but suddenly its taking ages just to load a single page and mostly not loading at all.
The DB looks fine,
I've restarted the site,
recycled the APP pool,
looked in the logs, it just looks like jibberish
Does anyone have any ideas as to how I can investigate further. No I am not asking you to fix my site or tell me why it is not working, I just want to know other methods for investigating the problem so I can get to the bottom of the issue.
IIS LOG:
http://pastebin.com/msjzty7m
Thanks
Use Google Pagespeed Insights to see where the problems might be.
I have a couple of suggestions:
Set up the ELMAH error log and take a look if some unhandled expcetions.
Set up mini profiler, maybe it is a bottle neck inside a new added script.
Use google PageSpeed Insights to analyze your pages.
My first guess would be it is infact a data issue. Not that it's taking a long time to grab the data but to process it. I've had a few times now where a page is around 138Kb but took over 3 seconds to wait for the page before rendering. Basically this was cause it was running a 3 tier repeater (repeater inside repeater inside repeater) to create the menu system. So even though the site wasn't big it was taking time processing this menu before sending it out.
Suggestions from me would be to comment out anything new that you've added before this date and bring stuff back in slowly till you find the problem part. After that you can look at caching. And if it's a module (.ascx) use # Output Caching and that could help.
This is not loading at all... the online tools can not help, you need to investigate whats happens on the server.
The tools for that is the process explorer from sysinternals to see what is running slow your server, then the autoruns to see what you loading with out your knowledge and also slow down your system, and the tcpView to see who is connected to your server.

Speed up web application compilation

I have tried looking at "related" questions for answers to this but they don't seem to actually be related...
Basically I have a VB.Net application with a catalogue, administration section (which can alter the catalogue, monitor page views etc etc) and other basic pages on the customer front end.
When I compile and run the app on my local machine it seems to compile fairly quickly and run very fast. However when deployed on the server it seems to take forever and a day on the very first page load (no matter what page it is, how many stylesheets / JS files there are, how many images there are, how big the page markup is and so on). After this ALL the pages load really fast. My guess is this is due to having to load the code from scratch; after that, until it is recycled, the application runs perfectly fast. Does anyone have any idea how I could speed this part of the application up? I am afraid that some customers (on slow connections such as my own at less than dial-up speed) may be leaving the site never to return as a result of it not loading fast enough. Any help would be greatly appreciated.
Thanks in advance.
Regards,
Richard
PS If you refer to some of my other questions you will find out a bit more about the system, such as the fact that most of the data is loaded into objects on the first page load - I am slowly sorting this out but it does not appear to be making all that much of a difference. I have considered using Linq-to-SQL instead but that, as far as I know, does not give me too much flexibility. I would rather define my own system architecture and make it specific to the company, rather than working within the restrictions of Linq-to-SQL.
If you can, the quickest easiest solution is simply to configure the AppDomain not to recycle after a period of inactivity. How this is accomplished differs between IIS 6 & IIS 7.
Another option is to write a small utility program that requests a page from your site every 4 minutes and set it up as a scheduled task on another PC that is on all the time. That at least will prevent the timeout and consequent AppDomain recycle from happening. It is a hack, to be sure, but sometimes any solution is better than none.
The proper solution, however, is to precompile your views. How exactly to accomplish and deploy that will depend on the exact type of Visual Studio project your web site is.

What is the best tips to improve the Application Performance in Asp.Net?

Can any help regarding the performance improvement in Asp.Net?The best practise tips for asp.net performance improvement?
This is a very broad question to answer because the Performance of an ASP.Net application is not only bound to page processing or bandwidth usage but also in the code and Algorithms you have written. If you use data source then the Performance of the Queries and ADo.Net. The Basic thing you might be asking is to improve page processing by Caching, etc..
Have a look here for a detailed description of Best Patterns and Practice (Though its old ..published in 2004 but still helps).
http://msdn.microsoft.com/en-us/library/ff647215.aspx
Or better consider this (For .Net4) . It list all performance related Documentation
http://msdn.microsoft.com/en-us/library/cc668225.aspx
Update
If you are looking for specific stuff slowing your page load
Use firebug's Net panel and monitor which resource is taking more time. Or as suggested by another answer use Tracing to check this out.
What is the best drug to get healthier? It all depends on what is your health problem. The same thing is with ASP.NET performance. First, find what is your bottleneck, a single most slow down factor. Then fix it, retest performance and, if more speed is necessary, go to the previous step.
How to find a bottleneck? If you really have no clue where to start, then start from analyzing your waterfall diagram. To create one from your client, use Fiddler or Firebug. To create it from different Internet geographies use WebPagetest. The waterfall will show whether the bottleneck is on the server or network, and also whether it is caused by main ASPX page or by resources (scripts, images, CSS). If the server and network are fast enough, then check slowness in the browser using Firebug or dynaTrace Ajax edition that can trace DOMContentLoaded/load events in browser. If the bottleneck is on the server, find out whether it is the database or application. Use database profiler and .NET profiler, for example from this question.
How to fix bottlenecks? Check this Microsoft resource, but there are many others for each type of bottlenecks.
If you add the “performance“ tag to your question you may get more answers.
Set trace="true" in the page directive. Reload the page and look for any obvious delays in the page life-cycle event handlers, particularly where you are accessing a database.
Also, use the Firefox Web Developer toolbar to obtain a friendly overview of the image file sizes and other static file sizes, CSS, JS, etc.
There are lots of questions and answers on ASP.NET performance here on Stackoverflow. Here's one of my previous answers and a quick search on the ASP.NET and Performance tags yields plenty of results.
What problems are you facing exactly?

tracking down slow performance of an ASP.NET web page

I want to find out the reason for slow performance of some web pages of an ASP.NET intranet website. the reasons could be many like large view state, number of round trips to the server and database, inefficient code in UI/middle tier etc. most of these slow pages are complex web pages with some third party controls, user controls.
what is the quickest way to find out what is causing the page to slow down without debugging each and every interaction on the web page and stepping through lines of code. will the code profilers like ANTS be of any help? or are there any better ways? there could be many factors for slow performance of a page, but I want to fix them in priority order.
thanks,
Rama
You can use a firefox addon named yslow whcih analyzes web pages based on Yahoo's performance rules.
If you want to check code performance then you can use a profiling tool.
For SQL there is SQL Server Profiler.
For .Net you can use ANTS Performance Profiler
Use Fiddler or HTTPWatch to profile the web application, this works with IE too..
And
I just came across a interesting post by john resig - deep tracing IE about the new client side profiler tool for IE. It is awsome & Its free.
You can get it here
If your web application is creating trace files then stop the web site, delete all archive trace files and restart the web site. It helped me to resolve the issue.
Try FastSQLDataSource. It helps when you need faster display of large amounts of data in your web application using grids, lists and other bound controls.
http://www.nitrosbase.net
It can work almost without coding or sometimes with no coding at all.
Some addtions:
Search for unproper Exception handling / throwing etc.
Search for left debugging code - one System.Diagnostics.Debug.WriteIf in a large loop or dataset is devastating
search for multiple databinding - broken page life cycle
search for code smell - the shit smells before hitting the fan ...

Resources