Skip to main content

Posts

How is Routing done in ASP.Net MVC

How routing is done in asp.net mvc Each route contains the following info, 1. the url 2. the curly braces that specify the match 3. the constraints for the inputs in the url parameters Each route should be anything that inherits from the RouteBase. **************** foreach route in the routescollection do, { 1. The url in the route should match the incoming url 2. The contents for the curly braces must match in the incoming url 3. The constraints should also match with the route taken from the routes collection. 4. If a match occurs, then the route is considered as a valid one } for every route match to be done, the routebase supplies the URL, the curlybrace dictionary with its replacement from the request URL, route parameter values with the optional ones for which no value was received from the i/p request. 3. The route handler is passed with the requestContext [url, cookies, authentication data, request data etc] once a first route match is done, the routing me

Sliding and Absolute expiration in Caching

Caching Mechanism and Its Expirations ASP.net cache or AppFabric Caching are ways to  increase the performance of the web application by r educing server round trips to database. However the validity of the cached data needs to be ensured, to enforce this, we have the following options 1. Dependency Mechanisms:      Files, SQL Cache Dependency etc This ensures that the cache is re-validated or refreshed once a dependent has changed or been altered 2.  Expire Cache:      The cache will expire after a time frame and the newer items will be added to cache when ever accessed or processed after expiry.  In Cache Expiry, we have the following options 1. Absolute Expiration:   Absolute expiration means It will expire cache after some time period set at the time of activating cache. This will be absolute expiration whether cache will be used or not It will expire the cache. This type of expiration used to  cache data which are not frequently changing. 2. Sliding Expiration: 

Constructors for user defined Exceptions in C#

The following are the rules that are to be adhered to when creating any custom user  defined exception. 1. Follow the Naming convention so that the self-explanatory name of the exception ends with Exception like: ArgumentNullException. 2. The following constructors should be defined public NewException() public NewException(string message) public NewException(string message, Exception exception) protected or private NewException(SerializationInfo serializationInfo, StreamingContext streamingContext) These ensure that the created Exception satisfies the default rules of User Defined Exceptions. [Also Satisfies FxCop Validation] -- Saravanan

Handling Enumerations in C# as Strings

In Order for an Enumeration in C# to be processed as a string, use the string formats described below, Sample: enum Colors {Red, Green, Blue, Yellow = 12}; Colors myColor = Colors.Yellow; myColor.ToString("g") = Yellow myColor.ToString("G") = Yellow myColor.ToString("x") = 0000000C myColor.ToString("X") = 0000000C myColor.ToString("d") = 12 myColor.ToString("D") = 12 myColor.ToString("f") = Yellow myColor.ToString("F") = Yellow As shown in the above samples, the following format specifiers :   g,G,x,X,d,D,f and F are used to convert a integer based enum value to string format. -- Saravanan