a. – Abstract Factory
a. – Hashtable,
a. – Abstract Factory
a. – Hashtable,
Here is a short notes I made for my reference, which I guess somebody who is getting started might find it useful.
– helps to perform logic before an action method is called (pre-action) or after an action method runs (post-action).
Filter Types :
1. Authorization Filters :
– Implements IAuthorizationFilter
– makes security decisions about whether to execute an action method, such as performing authentication or validating properties of the request.
– runs before any other filter
– Ex : AuthorizeAttribute, RequireHttpsAttribute
2. Action Filters
– Implements IActionFilter
– runs at Pre-Action and Post-Action
– can perform additional processing such as providing extra data to the action method, inspecting the return value, or canceling execution of action method.
3. Result Filters
– Implement IResultFilter
– can perform additional processing such as modifying the HTTP Response
– ex. OutputCacheAttribute
4. Exception Filters
– Implements IExceptionFilter
– executes if there is an unhandled exception thrown during the execution of the ASP.NET MVC pipeline.
– can be used for tasks such as logging or displaying an error page.
– ex. HandleErrorAttribute
Controller class implements each of the filter interfaces. We can implement any of the filters for a specific controller by overriding the controllers On<Filter> method.
Ex: OnAuthorization, OnException, OnActionExecuting, OnActionExecuted, OnResultExecuting, OnResultExecuted
Filters Provided in ASP.NET MVC – are implemented as attributes
1. AuthorizationAttribute – restricts access by authentication and optionally authorization
2. HandleErrorAttribute – Specifies how to handle an exception that is thrown by an action method
3. OutputCacheAttribute – provides output caching
4. RequireHttpsAttribute – Forces unsecured HTTP requests to be resent over HTTPS.
Filter Order – Filters are run in the following order
1. Authorization Filter
2. Action Filter
3. Response Filter
4. Exception Filter
Bundling is the process which makes it easy to combine or bundle multiple files into a single file. Fewer files means fewer HTTP requests that can improve first page load performance.
Minification is the process of removing all unnecessary characters (whitespace, newline, comments, block delimiters which are used to add readability to the code but not required for execution) or shortening variable names to one character (it can be a form of obfuscation) from source code without changing its functionality. It reduces the network traffic and improves request load time. It is different than compression, in that the minified source can be interpreted immediately without need for uncompression.
Both apply well to CSS, Javascript and other bundles.
Bundling and minification is enabled or disabled by setting the value of the debug attribute in the compilation Element in the Web.config file.
<system.web>
<compilation debug=”true” />
<!– Lines removed for clarity. –>
</system.web>
To enable bundling and minification, set the debug value to “false”. You can override the Web.config setting with the EnableOptimizations property on the BundleTable class. The following code enables bundling and minification and overrides any setting in the Web.config file.
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle(“~/bundles/jquery”).Include(
“~/Scripts/jquery-{version}.js”));
// Code removed for clarity.
BundleTable.EnableOptimizations = true;
}