Friday 31 August 2018

ASP.NET MVC: Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction

These are the common yet confusing Html helpers provided by ASP.NET MVC Razor Views.

Html.Partial() and Html.Action() returns MvcHtmlString. This means, it writes your output in parent view first and then return complete result to client's browser.
  • These methods are less resource intensive.
  • Slower than 'render' methods.
  • Should be preferred if your website has heavy traffic.

Html.RenderPartial() and Html.RenderAction() have void return type. This means, they write nothing on its parent view. So how do we still see the output? The answer is- these methods write output directly to the response.
  • Consume resources more.
  • It is faster method because it is rendered separately.
  • Should be preferred if your website has inadequate traffic.

Html.Partial() and Html.RenderPartial() can be used without an action method. If your parent view already has a model, you can pass that model to sub view you are trying to render.


Html.Action() and Html.RenderAction() can only be used with an action or child action. Use it when child view will have independent model.

More comments are welcome! :) 

Decrease size of Excel 2016 Workbook

Some of our clients use Excel Workbook to collaborate in SharePoint 2016 on-prem. One workbook had 9 sheets in it and the total size was 6 MB.

Later, a team member copied a sheet into it from another workbook and suddenly file size increased to 80MB. After that, it started opening super slow for all users and we started receiving complaints about it.

After looking at the document that why the size has increased that much we found-

  • Use of different colors all over new sheet.
  • Some cells have some comments in them.
  • Data was not a lot. (Confusing!!)
  • There is no formula used in sheet. (which is not the cause of increased size.)

Solution:

I saved the workbook in Excel Binary Workbook .xlsb from .xlsx.
File size reduced to 10 MB.