Monday, January 24, 2011

Accessing Data with ADO.net 4.0

EDM splitting

The key factor for Entity Splitting is both entities should share a common primary key

Friday, January 7, 2011

WebSite Performance Improvements

1) ViewState

Keep you viewstate light or no viewstate wherever possible

Note : Prevent any user from obtaining any part of the view state by using PageStatePersistor class http://aspnetresources.com/blog/page_state_persisters_overview

Scalability and Distributed Caching

This topic I need to learn more. Will soon update with more feeds

Things to do to scale you web application

1)Use SQL Server replication

also refer to http://www.c-sharpcorner.com/uploadfile/gopenath/page107182007032219am/page1.aspx

MultiThreading in Asp.net Web apps

Multi threading in asp.net can be achieved using two ways
1)Using BackgroundWorker class
2)Spanning new process thread on user interaction

While handling resource intrinsic operations concurrently like sending 1000s of email on a button click we have to use a separate process for every user

If the operation is global to the application but needs to be done in background then use Backgroundworker class

Error Handling

1) In MVC we can centralize the logic for handling and logging unhandled exceptions
by Decorating the controller classes with the [HandleError] attribute
Using the above class level attribute we can handle exceptions of specific type with separate customized views. There are other Action Filter attributes also [Authorize],[OutputCache]

Pls look into below link for details
http://www.pnpguidance.net/post/ASPNETMVCFrameworkPreview4HandleErrorAuthorizeOutputCacheActionFilterAttributes.aspx


Developing Web Application to be optimized for Search Engines

The key features responsible for optimizing our web application for Search Engines. Listing out one by one

1)HTML rendered by the web application
set the Render Outer table property to false on all Form View controls

MCPD 4.0 preparation

I am consolidating the key features in .net 4.0 during the process of learning for MCPD certification


1) Client ID mode property for user controls

Very useful property settings while referring to user controls from client side javascripts of the parent page. Setting ClientIdMode property to the value "Predictable" will remove all unwanted long strings before the id of the user controls. For more info refer to
http://blog.hmobius.com/post/2010/02/25/ASPNET-Part-8-Introducing-ClientIDMode.aspx


2) [DebuggerBrowsable] attribute

If you want to hide a class member variable from display to users even in debugging mode follow the 2 steps. Make the variable private and also decorate it with DebuggerBrowsable] attribute . For more details pls check
http://www.dailycoding.com/Posts/using_debuggerbrowsable_attribute_for_a_better_view_in_debugger_window.aspx



3)HTMLHelper Extension methods
These extension methods are used for programmatically adding reusable user-interface code to views and allowing the user-interface code to be rendered from the server side. These methods will render HTML controls. You can use helper methods that map to different HTML tags on the fly. (eg)<%= Html.Span("About page...") %>



4) MVC-RenderPartial vs RenderAction extension methods
There is a big difference between renderaction and renderpartial. RenderPartial will render a View on the same controller (or a shared one), while RenderAction will actually perform an entire cycle of MVC, that it, it will instantiate the controller (any controller you mention, not the current one only), it will execute the action, and it will then return and render the result.
http://stackoverflow.com/questions/719027/renderaction-renderpartial


http://www.slideshare.net/1kevgriff/aspnet-mvc-from-the-ground-up





5)Configure the Web application for constrained delegation
If you want the database to be accessed under the identity of the user connected to the web application then use constrained delegation



6)Avoid SessionID spoofing by inheriting SessionIDManager class and Customizing it.
in situation when sessionstate =cookieless in web.config



7)Keeping connectionstrings in external source and avoid web app restart on modifying the machine.config file
First we need to specify the configsource property to an external file.Keep the external file extension as .config as other file types can be browsable through webURL. Inorder to read the config entries from external config file we need to maintain the same config section in the external config file
http://aspalliance.com/820





8)To set the culture and UI culture for an ASP.NET Web page programmatically
1.Override the InitializeCulture method for the page.
2.In the overridden method, determine which language and culture to set the page to.



9)Nullable types:The ability to assign null to numeric and Boolean types
eg) int? num = null;



10) MVC2- Area
To accommodate large projects, ASP.NET MVC lets you partition Web applications into smaller units that are referred to as areas. Areas provide a way to separate a large MVC Web application into smaller functional groupings. An area is effectively an MVC structure inside an application. An application could contain several MVC structures (areas).
When you add an area to a project, a route for the area is defined in an AreaRegistration file. The route sends requests to the area based on the request URL. To register routes for areas, you add code to the Global.asax file that can automatically find the area routes in the AreaRegistration file. add the below code isn global.asax
AreaRegistration.RegisterAllAreas();

11)Render values from resource file in asp.net controls
eg) <asp:TextBox runat="server" Id="text" Text="<%$ Resources:WebResources, lblCompanyText %>"/>





12)

Accessing Data with ADO.net 4.0



POCO-Plain Old CLR objects

http://blogs.msdn.com/b/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx
http://blogs.msdn.com/b/adonet/archive/2009/05/11/sneak-preview-persistence-ignorance-and-poco-in-entity-framework-4-0.aspx
http://blogs.msdn.com/b/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx

Patterns behind the concept of Entity Framework is
The Repository Pattern http://msdn.microsoft.com/en-us/library/ff649690.aspx
Unit of Work

Eager Loading Vs Deferred(Lazy) Loading
http://blogs.msdn.com/b/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx


CSDL, SSDL, and MSL Specifications
CSDL-Conceptual Schema Design Language
SSDL-Store Schema Design Language
MSL-Mapping Schema Language




13) Dynamic keyword in c#4.0
Example for using Dynamic keyword
object calc = GetCalculator();
Type calcType = calc.GetType();
object res = calcType.InvokeMember(
"Add", BindingFlags.InvokeMethod,
null, new object[] { 10, 20 });
int sum = Convert.ToInt32(res);
Th e function returns a calculator, but the system doesn’t know the
exact type of this calculator object at compile time. Th e only thing
the code relies on is that this object should have the Add method.
Note that you don’t get IntelliSense for this method because you
supply its name as a string literal.
With the dynamic keyword, this code looks as simple as this one:
dynamic calc = GetCalculator();
int sum = calc.Add(10, 20);
The assumptions are the same: There’s some object with an
unknown type that we expect to have the Add method. And similar
to the previous example, you don’t get IntelliSense for this method.
But the syntax is much easier to read and use and looks similar to
calling a typical .NET method.