How to Improve ASP Net MVC 3 View Performance

What is a View ?
  • Incoming browser requests are mapped to controller actions
  • A controller action might return a View
  • View handles the display of the data
  • Most often the Views are created from the ViewModel data

MVC

How to Improve View Performance ?

Tip 01 :  Run in Release Mode
  • You should always make sure that your application is Compiled in Release Mode
Compiled in Release Mode
  • Your Web.config file Must Looks Like below on Production
         <compilation debug="false" targetFramework="4.0">
         <assemblies>

        </assemblies>
     </compilation>

   Why This Needs ?

      #  MVC Will Not do any View Look-up Caching if you are running your application
            in Debug Mode

Tip 02 : Use only the View Engines that you need

  • MVC framework supports having multiple view engines
  • Can Configured simultaneously in your application
  • And will query each in turn when it is trying to find a View
  • In MVC 3 we register two view engines by default (WebForms and Razor)
  • There is no reason to pay the performance price for something you are not using
  • So make sure you specify only the view engines you need in your Global.asax file
         Global.asax  file Looks Like below :

      protected voidApplication_Start()
        {
          ViewEngines.Engines.Clear();
          ViewEngines.Engines.Add(new RazorViewEngine());//add razor view engine
        }

Tip 03 Avoid passing null ViewModels to Views

     When it Happens ?
  • You pass in a null ViewModel to a View that uses strongly-typed html helpers 
           Such as in the View :

              @model PawLoyalty.ViewModels.Product
          
      @{
                
              @Html.TextBoxFor(m => m.ProductName); 
       
       }
  • This frequently happens in Insert (Add) scenarios

    Why is it Bad ?
  • Strongly-typed html helpers like above,
  • Will try to emit the value of the ViewModel using the provided expression
  • However when something along the expression chain is null a NullReferenceException will be thrown,
  • When the expression gets evaluated,
  • MVC’s expression evaluator catches the exception
  • But on a page with multiple such html helpers the cost of the exception adds up
  • You can avoid that cost by always passing an instance of the ViewModel to the View

    Bad Way :

        [HttpGet]
        public ActionResult Add() //get empty data for user input operation
        {
            returnView();  //here the model instance defaults to null
        }

    Best Way :

        [HttpGet]
        public ActionResult Add()//get empty data for user input operation
        {
          returnView(new Product());//here the ViewModel Product has been sent
        }



Tip 04 Uninstall URL Rewrite if you don’t use it

  When it Happens :
  • Your IIS server has the URL Rewrite module installed
  • When you are running ASP.NET MVC 3,
  • None of the applications on the server are using it

            What is URL Rewrite ?

               #  Enables Web administrators to create powerful rules to implement URLs
               #  That are easier for users to remember and easier for search engines to find

Why is it Bad ?

  • When performing URL generation (e.g : Html.ActionLink)
  • MVC 3 checks to see if the currently requested URL has been rewritten by the URL Rewrite module
  • The act of checking need significant computing power to solve (because it involves checking server variables)
  • So if you are not using URL Rewrite you should Turn it Off (Uninstall)

                   How to Uninstall URL Rewrite ?

                       # Win 7 --> Controller Panel --> Programs and Features -->

Uninstall URL Rewrite


             Important Note :  MVC 2 always performs this check.So turning
                                         URL Rewrite off  (uninstall)  will not make a difference


Tip 05 Enabling Output Caching

    What is Output Caching ?

  • Enables you to cache the content returned by a controller action
  • The same content does not need to be generated each and every time the same controller action is invoked
  • Caching enables you to avoid performing redundant work on the Server
  • Can apply for either individual controller action or an entire controller class

   How to Do That ?

  • Using [OutputCache] attribute

    Lets take a simple Example

    public class HomeController : Controller
    {
      [OutputCache(Duration = 10, VaryByParam = "none")] //cached for 10 seconds
      public ActionResult Index()
      {
          returnView();
      }
    }

   When to Use it ?
  • Read operations Only

  When Not to Use it ?
  • Writes operations.Such as Update,Delete and Inserts 
  • Pages which are User Specific.e.g. shopping cart page

Summery of Performance Gain Chart :

Performance Gain Chart

                        Pages/Sec - How many pages can load per second

                        Page Time (ms) - How long will it take to load a page

                        Base - Page that has not done any performance gain operations

Conclusion
  • You can see that highest performance gain can get by using OutputCache operation
  • But OutputCache having its own Limitations
  • I will explain more about MVC caching in My future blog post
  • If your page is load under 1 second then you may not worry too much about performance gain

I hope this helps to You.Comments and feedback greatly appreciated.

Happy Coding.

MVC Related Articles


Read More..

Windows 7 RC1 under test at Hillier Consultants

Windows 7 Release Candidate 1 is now being run on one of our computers as a production machine.
Our set up is that all workstations connect to our domain server and all data is stored on that server so there is no locally stored data. Thus we can test Windows 7 in a real working environment without the risk of losing any data if things go seriously wrong.
The first viewing of Windows 7 beta left us unimpressed, however this release does seem a litle better.
It installed fine. Just a little annoyance when first installing there is a long delay without any progress bar while the disk is being formatted. Beyond that the install was trouble free. Most drivers were installed without the need for manufacturers disks but when we did the Vista drivers seemed to work OK.
We connected it to the domain without problem and at first glance it appeared to access the local network with better response times than Vista.
Internet access also seems to be improved.
The comparison with Vista is acute because we have set both machines to use a single keyboard, mouse and monitor via a KVM switch. Transferring from Vista to Win7 goes a dream, however there is a delay before mouse and keyboard respond when going from Win7 to Vista.
We are not installing MS Office on this machine yet but we have installed Open Office, Firefox & Thunderbird, Opera, Safari and FileZilla all of which loaded fine and seem to work without issues.
We installed Free AVG antivirus (Vista version) pro temp and this seems to be fine.
We are only at the end of our first 24 hours of testing so it is early days.
We will keep you posted of significant issues as we find them.
Read More..

Poll Results Autodesk release Cycle

CAD-a-Blog conducted a readers poll (completely unscientific of course) to see how often you think Autodesk should release a new version of AutoCAD. This seems to be a hot topic at the moment due to many users unhappiness with AutoCAD 2009.

Here is what you said:

Out of 45 readers participating (I know, not that many) nobody wanted a 6 month cycle. I dont even think this is possible unless there is only one item to the update.

2% of the voters would like to see an 8 month cycle!! Thats fast, and again, Im not sure thats possible either.

4% wanted a 12 month (or yearly) cycle, which Autodesk has done since the 2003 release of AutoCAD 2004. It would seem that most people are unhappy or not fully satisfied with this type of a cycle.

13% would like to see an 18 month cycle which would be every year and a half, or two releases in a three year period. They would like to see Autodesk take a little bit more time to work on the program.

49% of the voters would like to see a 24 month, or bi-annual release of AutoCAD, thats almost half.

31% of users participating said a 36 month or three release cycle is the way to go. Is that too long of a wait?
-------------------------------------------------------------------------

Well, this pole is clearly not scientific, or far reaching enough for us to make any conclusions about the users. However, it does seem to coincide with other polls and discussions on the internet. It seems that keeping up with AutoCAD every year is becoming a hassle for many of its users, managers, and companies.

How long before this rapid release cycle takes a big enough toll on companies where they stop upgrading every year? there are many problems with a yearly release cycle on the users end, cost is the biggest, or course. Everything comes down to the bottom line. Autodesk has to serve not only their clients, but their stockholders. In fact, the big guns in charge at Autodesk answer first to the stockholders. The stockholders answer to their desire for valuable stock. In order to affect change in the stockholders perspective, the stock has to change value. The more profitable it is the more they will stay the same, and more of it. The less valuable it is, the more likely they are to change policy.

My point here is that everyone involved is in this thing to make money. Autodesk wants to make money selling the software to users. Users want to make money selling drawings, models, etc. by using the software. Perhaps the best question to ask is what do the users clients need? That will dictate what the users will purchase and how they will work and for how much. Which will in turn direct Autodesk on what and how to produce in their software.

Sometimes the software provider, in its interest, has to create a need, hence the verticals of AutoCAD. Many users didnt know that they needed new and improved software to do their jobs until it was available. Its like color TV. Nobody knew the needed it until it was available. they were happy with black and white TV.

Thats my two cents, please dont ask for change!!

Happy CADDING.
Read More..

Who has a 3D mouse

If you have one, what kind is it?  How long have you had it?  What do you like/dislike about it?  Would you recommend it?  Was it worth it?

If you dont have a 3D mouse, why?  Are you planning on getting one?  What is keeping you from getting one?  Price? Wont use it enough? Dont do 3D? What is your opinion about them?  Have you ever tried one?  Do you want to?
Read More..

HOWTO Setting up a Penetration environment with VirtualBox

*** CAUTION : This tutorial is written for Penetration Test only. Otherwise, you may be arrested if you attack/intrude any other network/computer without authorization. ***



Software :

Back|Track 4 R1

Ubuntu 10.10 Desktop

VirtualBox 3.2.10 r66523



Hardware :

Lenovo ThinkPad X200 with 4GB RAM and 80GB SSD



Lenovo ThinkPad X200 is installed Ubuntu 10.10 Desktop edition. On which, installs VirtualBox.



Go to the Oracle VM VirtualBox site to download the VirtualBox :

http://dlc.sun.com/virtualbox/vboxdownload.html#linux



(A) Create Back|Track virtual machine :



Select at least 8GB virtual hard drive place and 512MB RAM for the Back|Track. The first network adapter is set to "NAT" while the second is set to "Host-Only".



Boot up Back|Track from the VirtualBox and click on "install.sh" to install Back|Track.



Login for further setting. The username is "root" and the password is "toor".



Step 1 :



After the installation, you may execute the following command to fix the screen size to 800x600.



fix-splash800



Then, change the password of the root when necessary. Otherwise, the username is "root" while the password is "toor".



Execute the following command to make Back|Track to start network interface and X.org when bootup each time.



kate /root/.bash_profile



Append the following lines :



start-network

startx




Step 2 :



To install VirtualBox Additions when necessary via "Konqueror" -- "Storage Media" -- "media:/hdc".



bash VBoxLinuxAdditions-x86.run



Step 3 :



apt-get -y update

apt-get -y upgrade




Step 4 :



Go to "Menu" -- "BackTrack" -- "Penetration" -- "Fast Track". Select "Fast-Track Interactive" and choose "1".



Step 4a :



Go to "Menu" -- "BackTrack" -- "Penetration" -- "ExploitDB". Select "Update Exploitdb".



Step 4b :



Go to "Menu" -- "BackTrack" -- "Penetration" -- "Social Engineering Toolkit". Select "S.E.T-Update".



Step 5 :



At the terminal, execute the following command :



airodump-ng-oui-update



Step 6 :



Go to "Menu" -- "BackTrack" -- "Vulnerability Identification" -- "OpenVAS" -- "OpenVAS NVT Sync".



Step 7 :



Update the Add-ons of Firefox.



Step 8 :



apt-get -y install crark

apt-get -y install wbox

apt-get -y install vlc




Step 9 :



Update the Framework. However, it will take several hours.



cd /pentest/exploits/framework3/

svn up




Step 10 :



Reboot the system.



(B) Create Metasploitable virtual machine (Optional)



Go to the following link to download the "Metasploitable" which is an Ubuntu 8.04 server with some flaws.



http://blog.metasploit.com/2010/05/introducing-metasploitable.html



Set the downloaded Metasploitable as virtual hard drive at VirtualBox. The network adapter is set to "Host-Only". The virtual hard disk space is at least 8GB and 512MB RAM for the Metasploitable.



(C) The final



Now, the IP address of eth0 of Metasploitable is similar to 192.168.56.101. The IP address of eth0 and eth1 of Back|Track are similar to 10.0.2.15 and 192.168.56.102 respectively.



You may require to execute the following command at Back|Track in order to see the two network interfaces and their IPs.



/etc/init.d/networking restart



Back|Track can access (or ping) Metasploitable via IP address. Back|Track can surf the internet but Metasploitable cannot.



At last, your penetration environment is set up.



(D) Free Tutorials



(1) Metaploit Unleashed

(2) Fast-Track

(3) Social-Engineer Tootkit

(4) Got Milk?

(5) How to Metasploit Beginner to Advanced (Video)



(E) Non-free Training



Offensive Security



(F) Resources



(1) Exploits Database

(2) Metaploit Blog

(3) Offensive security Blog

(4) Yet another Back|Track in Gnome

(5) Metasploit



Thats all! See you.
Read More..

CADspeed article Tips on Buying Wide Format Printers for CAD Part 1 Determine Your Needs

Are you or your company about to get a new printer?  Before you do, check out my latest article for CADspeed.  Its part One of a three part series.  In it I look at your needs, wants, and help you to come up with a plan to make sure you get the printer thats right for you.

Check it out!
Read More..

How to Remove Antivirus Live Uninstall Antivirus Live Easily With Removal Instructions

What is Antivirus Live? Its frighteningly powerful at the moment. This fake antivirus software makes it nearly impossible to run your computer normally. It blocks your programs from operating, and it starts itself automatically every time Windows starts. This virus is infected through a Trojan, meaning tracing its entrance is difficult to do. A unique and annoying aspect of Antivirus Live is the way it affects your proxy settings and makes it nearly impossible to run Internet Explorer. Antivirus Live will try to rob you of your money for what it claims to be "fully activated" software. Its bogus. You have to remove this virus quickly before any irreperable harm is done.
The tell-tale signs of a fake antivirus infection are normally pop-ups, computer slowdown, and fake scans that start every time you boot your computer. Antivirus Live is no different. When it is running you will get all of the pop-ups, security alerts, warnings, and taskbar messages. You will receive official looking Windows warnings that will oddly suggest that you install Antivirus Live in particular. Normal Windows software will never recommend a particular program like this fake version does. This fake antivirus software will do whatever it can to scare you into shelving out your money. Dont fall for it!
How Do I Uninstall Antivirus Live?
To remove this software you wont be able to simply Add/Remove it. Deleting the program files wont be enough, either. This rogue software embeds itself into your system, into your registry, and disrupts your proxy settings. You can consider trying to remove it yourself, also known as manual removal, if you consider yourself an IT pro or a bigtime techie. The reason is that editing your registry is no laughing matter, as one mistake can conclude in large fees at a technicians shop or a computer that wont start up anymore. If youre a pro, youll have to delete all related DLL and LNK files in your LOCAL_HKEY_USER

Article Source: http://EzineArticles.com/3407009
Read More..

Blog Archive

Powered by Blogger.