Performance optimization in ASP .NET applications

Answer by Sharmilli Priyadarsini:

If you are using SQL server or an equivalent database in the background to process your data, try the below steps:
1. Process most of the data in the database and transfer only the required result set to the application layer.
2. If you have used store procedures or functions, run a profiler in the the database administrator and understand which of your queries consume more time(Usually due to unwanted joins). Optimise the expensive queries.
3. Ensure you have removed unnecessary lines of code added during debugging to print values has been removed and you have followed the best practices.

Now, if you are using an ORM like Entity Framework, assuming you must have used LINQ to Entity to do the database querying, you can still do the database profiling to identify the expensive or time consuming code by running the database profiler and attaching it to the respective process.

If your front-end is taking consuming, run your Visual studio profiler from the Analyse menu, and see where are the code can be optimized. You can also use re-sharper to do code analysis.

Other key tips are,
1. Use server side pagination instead on the client side.
2. See if there are nested for loops or foreach loops used for data processing.
3. Push your data processing logic as much as possible to the database.
4. Make sure the memory management is taken care.

Hope it helps.

I’m developing a project on  ASP.NET  mvc . In a certain table it has 22246148 rows data and its taking 04:48 mins to retrieve the  recor…

Are there a general set of “best practices” or the like for implementing social networking elements in ASP.NET, MVC, and C#?, or maybe us…

Best Practices While Developing On-line Learning Platform using Microsoft Technology Stack

Answer by Sharmilli Priyadarsini:

I assume that you want to create a learning platform using .net and you are looking for components to simulate the feeling of social networking.

If that is the case, you should probably think about using the templates from CMS(content management systems) like Umbraco. Or if you are thinking about building your own the system, go by SDLC model.

1) Analysis – Make a thorough domain study to understand the preferences of your customer and see what is their actual expectation and how this system could benefit them.
2) Design – Split this section into two, High Level Design (HLD), Low Level Design(LLD). The high level design should cover the requirements on the business perspective and you should get the queries clarified through your customer on the number of users who are going to consume the software and your screen designs must be reviewed and confirmed by the customer before jumping into low level design document. In low level design, we need to look at the two aspects, backend design and front end design considering the customer expectations. This acts as a foundation for building the project architecture.
3. Development – Create your database and the required project layers considering HLD and LLD in your mind. Always go from the backend to the front end as the backend design could give you a clarity or wholistic picture on the software.Decide your technology stack based on your budget and customer requirements. Depending on the user base, you may have to decide the number of layers, If your application has enhancement plans to extend in different platforms, use Web services, can use SignalR for displaying the dynamic information like chats, real-time feeds etc. If you have database developers use direct database connectivity for optimum performance, if you do not have database experts, use an ORM like entity framework. Now, once the architecture is ready, start developing the modules one by one, perform unit testing to ensure the functionalies are working as expected and comply with the design documents.
Testing – After unit testing, your product should go through rigorous testing which includes functional testing, regression testing, performance testing etc. The defects identified from the testing should be fixed and it has to go through retest before rolling out to user acceptance testing. A few users gets to evaluate the product and provide feedbacks for product improvisation if any.
Delivery – once the product passes through all the above step, the product can be handed over to the customer.

Are there a general set of "best practices" or the like for implementing social networking elements in ASP.NET, MVC, and C#?, or maybe us…

Difference between @html.TextBox and @html.TextBoxFor

Difference between @html.TextBox and @html.TextBoxFor.

My answer on Quora:

In abstract terms, the difference between the html helpers @html.TextBox() and @html.TextBoxFor() are the former is weakly typed and is independent of model and the latter is strongly typed and it should be bound to one of the model property in strongly typed view.

Consider the below piece of code,

This will be rendered as shown in the below image.

When you use, TextBoxFor, while the HTML is generated, it will automatically map the value from the model property to it, in the above case “UserName” . So when you post the values of the current page, if your controller is having your model as the parameter, the value can be retrived directly by accessing the property.

When you look at the above screenshot, the model will not hold the weekly typed “simpleTextBox”.

Hope you find it useful.

Can any one explain me the difference between @html.TextBox() and @html.TextBoxFor() in MVC?

Model Binding and Strongly Typed Views

Model Binding and Strongly Typed Views

Answer by Sharmilli Priyadarsini:

In order to demonstrate model binding, I am making use of the default scaffold for Account registration available when you create a new web application with Visual studio.

Let us see how to create a strongly typed view using the below model,

Now, from your solution explorer, expand the controller folder and open the AccountController.

You will find something like the below action method,

Right clicking near the ActionResult and selecting go to view will navigate you to the Register.cshtml view which is strongly typed with “RegisterViewModel”. In order to make a view strongly typed, you can either do it through api or marking the model on the top of page as shown below:

Doing, so will generate you a strongly typed view as Register.cshtml bound to RegisterViewModel inside the accounts folder in views.

This is how you can create a strongly typed view. Now let us get into the detail of how to design your view by making use of the above model.When you take a close look of the above screenshot, you will see set of html helpers i.e all that follows “@html.” are said to be html helpers. Why because, they will generate the equivalent html to generate your web pages.

Let us take the below example
@html.LabelFor(m=>m.UserName, new{@class=”my-label”})
@ in the above line of code is known as razor syntax. Everything that follows the razor syntax will be rendered at the web server and are C# code in the .cshtml page and vb code in .vbhtml respectively.
html. represents that a html helper so the equivalent output will be a html code generated by the web server. we have different types of helpers like html helper, ajax helper etc.

LabelFor will generate a html label with the name user name which is strongly typed. But usually the label’s will not post the values to controllers they are just plain text. But if we have other controls like textbox, checkbox we can retrive their values in the controller.

Hope this clears your doubt.

I am getting quite confusion in binding the model data in view page, can any one explain me? How exactly it is done?

துயிலெழு பெண்மையே ! (Wake-up Womankind)

பிறர் ஏவல்செய்ய,
கைப்பாவை வேடம் போட்டாய்,
பிற்போக்கு சமுதாயம் பிழைசொல்லுமென்பதலா?
அவன்சொன்னான்! இவன்சொன்னான்! எவன்சொன்னல் உனக்கென்ன?
உன்கனவும், உன்னுயர்வும் உனக்கு மட்டும் சொந்தமில்லை,
யுகயுகமாய் அடிமைப்பட்ட உலகமகளிர் உயர்வதற்கு உண்பங்காய் இருந்திடட்டும்!

ஒழுக்கமற்ற உலகமிது,
நெறிகெட்ட பாகுபாட்டுப் புதையலிது!
ஈவிரக்கம் இங்கில்லை,(அது) உனக்கு மட்டுமெதற்கு?
பழுதடைந்த பண்பாடு அதன்பெயரில் அடிமைத்தனம் அனுமதியோம்!
கலவுபோனதோ மறுக்கப்பட்டதோ உன் சுதந்திரம், கொடுக்கப்படவில்லையேல் எடுத்துக்கொள்!

(Translation in English)
Hey Womankind,
Don’t be a puppet that others want you to be!
Wake up to live your dream that inspire yourself,
and the oppressed gender!
Hey Womankind,
The world is unfair and unjust,
show no mercy,
If freedom is stolen or denied, take it,
because it is yours!

What certification courses should be done if one wants to have a career as an ASP.Net developer? And in what sequence should they be appr…

Answer by Sharmilli Priyadarsini:

In my opinion,Certification does not count much. If you want to be a good ASP.NET developer , Just start mastering the skills instead concentrating on the certification. ASP.NET is evolving at a faster rate, every release is pooled up with new features. Its not just ASP.NET webforms, its much more we need to build up the profeciency on. We have MVC, vNext (Kathana), OWIN, SignalR. Now that ASP.NET becomes an opensource, so many OS frameworks are supported and so to be on the track, we constantly need to learn things. At least for an extend that we should be able to understand the basics of it. And yes, we need to build quality stuff, using the best practices while we develop stuff. After you have a minimum experience of 6 months to 1 year, take the certification in the area you are comfortable on. All the best!

What certification courses should be done if one wants to have a career as an ASP.Net developer? And in what sequence should they be appr…