How to make asp.net web forms application faster? - asp.net

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.

Related

Umbraco alternative?

I've been trying to learn how develop websites with ASP.NET as well as setup a personal website to use as a online porfolio/resume. With my website I've decided to not try to reinvent the wheel and thus decided to use a premade ASP.NET based CMS.
After reading a lot of reviews I settled on Umbraco, but now I'm seeking out alternatives. I like Umbraco a lot but I keep running into problems. Since installing it on my host I haven't made any changes through the file system, or database directly. All changes have been through the admin site. Yet somehow I kept getting it into some state where I could not delete a datatype, and now I'm having problems removing or renaming one of my templates. I've searched for Umbraco forums for solutions and usually find that I have to run some SQL script workaround on the database to clean things up. This kind of thing is really not something I want to fiddle with for my personal site.
Has anyone else had a lot of problems with Umbraco like I have? Are there other free CMS systems out there that are more reliable, yet similar to Umbraco? Specifically I really like how Umbraco gives me total control over the HTML generated by my site. Simple is also better in this case. I'm not trying to create some kind social network/community portal/forum/blog site. There won't be multiple people logging onto this site or anything like that.
I've been reading a bit about N2, which I'm now starting to consider. I like that it's more developer based and that you setup page types through real .NET classes in Visual Studio. Again I don't want to attempt to build my own CMS from scratch, but at the same time I really don't like how hard it is to see what's going on under the hood with most other CMS systems.
I haven't used N2 so I can't comment on that, but alternatives you can consider are Orchard or FunnelWeb, both are on MVC 3 and Razor.
If you're wanting a blog that is mostly just a blog then FunnelWeb is a good option.
I'm currently writing a comparison between Orchard and Umbraco if you're interested as well.
I think you'll be happy you stuck with Umbraco. I was so frustrated with Umbraco when I first started working with it for the exact reasons you stated above. The issue with not being able to delete data types could mean that it's connected to something (IE: document or media type) somewhere and if you force delete it (IE: via the db) you could really mess up your install. <- speaking from experience.
I'm absolutely in love with Umbraco now though. I am completely confident that I can build just about anything I need with it now.
I think that my best piece of advice I can pull from my own experience is make sure that you've got your site architecture planned out thoroughly before starting to build it out in Umbraco. You don't want to be fiddling around in there afterward changing things and that's where you can really get yourself into some hot water.
Have fun!
if you want a minimal .net mvc4 cms with good performance check out puck https://bitbucket.org/yohsii/puck/overview
it adds very few concepts on top of what you need to know for .net mvc but it does require .net4.5 (and therefore VS2012) to work with.
it also uses localdb out of the box but if you don't want to install that just attach the database mdf file to regular sql server and change the connection string

How can I convert a bunch of .asp to .aspx?

I want to port an existing, legacy, ecommerce website from ASP to ASP.NET.
What approaches do I have ?
is there a way to run an ASP file with an ASP.NET engine ?
are there tools to automatically convert ASP to ASP.NET and do they work on complex websites ?
other approaches ?
Thanks for your help
Jerome Wagner
No, but if you have Asp.NET on the server, that doesn't mean the Asp pages won't run anyway. Having Asp.Net installed does not break classic asp. However, newer versions of Windows come with classic Asp turned off by default, so you have to go into add/remove programs/add/remove windows components and drill down to install asp. And there's nothing to prevent you from having asp pages sitting side-by-side with Asp.Net pages in te same website, or even the same directory, so really the first question si not really an issue.
I've never heard of them. Classic ASP is so different from Asp.NET that it's just not feasible.
Manually, one page at a time. And that is an approach that has issues because sharing session between Asp and Asp.Net is not trivial and relies on hacks.
I know this isn't an answer to your question and it's probably none of my business, but in my experience, this may be a good time to look at a commercial ecommerce site. Several are out there at good prices. The amount of time you'll spend on this may be way less than you'd spend. Also, PCI rules and security issues have changed so much since classic Asp was a "real" development platform that you're definitely better off with a commercial app.
I say this from experience. We just replaced our old shopping cart with a commercial one after spending quite a bit of time going back and forth on our best approach. If you can afford it, i strongly recommend it.
The other answers are valid, so I'll only add that there is a migration tool of sorts provided by microsoft: The ASP to ASP.NET 1.x Migration tool . It doesn't claim to completely migrate a site, but may assist with a large portion of it. Of course, this assumes that a asp.net 1.1 site will run just fine on the latest incarnation of asp.net.
Step 1. Gather requirements for the new system
Step 2. Does anything exist that already meets your needs? if so, stop here and buy it.
Step 3. Build a data model and screen designs.
Step 4. Does the new system jive with the stake holders expectations. Go back to step 1 if necessary.
Step 5. Code new site
If necessary, review various standard project templates (scrum, waterfall, whatever). Pick one and stick to it.
You'll notice a distinct lack of anything remotely related to "converting" the old code / data files to the new platform. This is to preserve your sanity and help ensure the project will be a success.
To answer the actual question: no. You might as well have asked if there were tools to convert a php site to java. They are radically different things with their own approaches.

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 ...

How can I restructure my site without a conversion to MVC/WCSF?

I have a portfolio made in C#/ASP.NET which started off small but, as it is selling myself, it has grown in size very quickly.
I started off with using ASP.NET webforms model but this has meant that some of my code is in class libraries (.dlls) and some in page codebehind.
I want to fix this (no defined stucture), but without the overhead of migrating to ASP.NET MVC or WCSF.
How could I address these problems? I am thinking of moving all logic to WCF services and calling them from page codebehind. Is there a better way?
EDIT: The current problem is codebehind (used only as the site was small at the start but now it gets a lot of attention from me with updates). I want to seperate this all out so it's easy to test (what MVC addresses), and the coupling is generally low. Is it enough to use WCF to achieve this? What other techniques could I employ? Maintainability is another concern because maintaining a codebase split between .dlls is awkward (when debugging, as I noticed and mentioned in some previous threads).
Thanks
Unfortunately, traditional web forms applications are damn near impossible to test. WCF won't be of much help because it's a communications technology that will help you to get the data to codebehind classes but won't help you to render or test pages.
Due to this complexity, there are very few test automation tools, and the few there are are commercial paid-for products. One such tool I have heard of, but have not used personally, is Ivonna. You can also test using browser automation. Two great tools to help with this purpose are watin and WebAii.
This is, of course, dependent on whether you still want to keep the original code lying around. What I take in when I read your post is that you want all of the benefits of MVC. Unfortunately, it may be best to take the plunge and rewrite the application. It's painful, I know, but the sheer amount of hackery to make WebForms ape MVC concepts is overwhelming, to say the least.
I cant fully imagine what you need, but consider URL redirection / slug

Tools and methods for live-monitoring ASP.NET web applications?

I think many developers know that uncomfortable feeling when users tell them that "The application is slow (again)."
In a complex web application there can be many possible reasons for a degradation in (perceived) performance: slow database response, bandwidth issues, bad caching etc. There certainly are issues which will never occur in a development or staging environment.
Now my question:
Is there a set of tools and/or methods which would provide a comprehensive "live" state on a IIS/ASP.NET/SQL Server production system in a visually way (not just performance counters):
Current HTTP requests (say the last n minutes)
Exceptions / timeouts
Bandwidth data
Number of open database connections / database calls
...
The primary goal is to see at a glance (or after looking closer) what problem is causing the performance problems.
I think the category of software you're looking for is ".net profiler" or ".net tracer". One such tool that you might consider is JetBrains' dotTrace. It gives you runtime stack traces and an array of counters that indicate possible bottlenecks.
Previously mentioned tools will certainly work. At our shop we needed finer information and built our own solution (long story: it was easier to code than to argue about tools and retrievable data).
I used LogParser to flip through the IIS logs and create output reports of those logs (e.g. result code breakdowns etc).
I used a combination of performance counters and WMI values to get the rest - you can read these using some pretty straightforward C# - this gives you full control that you can then dump to .csv etc for viewing/processing in excel or if you are updating a page as a control center.
I would probably also look at IIS.net as a great resource for IIS tools including debugging, security etc.
I followed urig's advice and found this software called SmartInspect.
Does anybody know this logging/monitoring tool? It seems to be a combination of real time console and developer library.
CLR 4.5 will have some new capabilities that will help you monitor ASP.NET performance live - without restarting your app. Basically you can re-JIT your code to include some monitoring-hooks in it, and then inspect time spent in classes/methods etc.
I'm sure dotTrace and other profiling tools will leverage this automatically, but it's worth checking out: C9 - Inside Re-JIT with David Broman

Resources