<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2173981707919944244</id><updated>2024-10-24T18:11:04.506-07:00</updated><title type='text'>Asp.Net MVC 3</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://aspdotnetmvc3.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://aspdotnetmvc3.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>jivangoyal</name><uri>http://www.blogger.com/profile/12853371042810428434</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2173981707919944244.post-2976235850883262919</id><published>2013-07-24T07:18:00.001-07:00</published><updated>2013-07-24T07:20:58.167-07:00</updated><title type='text'>The Different Types of Filters</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
The ASP.NET MVC framework supports four different types of filters:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Authorization filters – Implements the &lt;code&gt;IAuthorizationFilter&lt;/code&gt; attribute.&lt;/li&gt;
&lt;li&gt;Action filters – Implements the &lt;code&gt;IActionFilter&lt;/code&gt; attribute.&lt;/li&gt;
&lt;li&gt;Result filters – Implements the &lt;code&gt;IResultFilter&lt;/code&gt; attribute.&lt;/li&gt;
&lt;li&gt;Exception filters – Implements the &lt;code&gt;IExceptionFilter&lt;/code&gt; attribute.&lt;/li&gt;
&lt;/ol&gt;
The base class for all action filters is the &lt;code&gt;System.Web.Mvc.FilterAttribute &lt;/code&gt;class.&lt;br /&gt;
To create a class that inherits from the base Filter class and implements one or more of the &lt;code&gt;IAuthorizationFilter&lt;/code&gt;, &lt;code&gt;IActionFilter&lt;/code&gt;, &lt;code&gt;IResultFilter&lt;/code&gt;, or &lt;code&gt;ExceptionFilter&lt;/code&gt; interfaces gives implementation for particular required filter. Filters are executed in the order listed above. For example, 
authorization filters are always executed before action filters and 
exception filters are always executed after every other type of filter.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Authorization filters&lt;/b&gt; are used to implement authentication and 
authorization for controller actions. For example, the Authorize filter 
is an example of an Authorization filter.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Action filters&lt;/b&gt; contain logic that is executed before and after a 
controller action executes. You can use an action filter, for instance, 
to modify the view data that a controller action returns.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Result filters&lt;/b&gt; contain logic that is executed before and after a view
 result is executed. For example, you might want to modify a view result
 right before the view is rendered to the browser.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Exception filters&lt;/b&gt; are the last type of filter to run. You can use an 
exception filter to handle errors raised by either your controller 
actions or controller action results. You also can use exception filters
 to log errors.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Customize order of execution: &lt;/b&gt;Each different type of filter is executed in a particular order. 
If you want to control the order in which filters of the same type are 
executed then you can set a filter&#39;s Order property. &lt;br /&gt;
e.g. &lt;span&gt;base &lt;code&gt;ActionFilterAttribute&lt;/code&gt; class has following methods:&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;OnActionExecuting – This method is called before a controller action is executed.&lt;/li&gt;
&lt;li&gt;OnActionExecuted – This method is called after a controller action is executed.&lt;/li&gt;
&lt;li&gt;OnResultExecuting – This method is called before a controller action result is executed.&lt;/li&gt;
&lt;li&gt;OnResultExecuted – This method is called after a controller action result is executed.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetmvc3.blogspot.com/feeds/2976235850883262919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2013/07/the-different-types-of-filters.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/2976235850883262919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/2976235850883262919'/><link rel='alternate' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2013/07/the-different-types-of-filters.html' title='The Different Types of Filters'/><author><name>jivangoyal</name><uri>http://www.blogger.com/profile/12853371042810428434</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2173981707919944244.post-561724383130892191</id><published>2012-12-13T08:11:00.002-08:00</published><updated>2012-12-13T08:11:13.957-08:00</updated><title type='text'>HTTP Basic Authentication against Non-Windows Accounts in IIS/ASP.NET (Part 2 – The HTTP Module)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Ref: http://leastprivilege.com/2008/01/12/http-basic-authentication-against-non-windows-accounts-in-iisasp-net-part-2-the-http-module/&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetmvc3.blogspot.com/feeds/561724383130892191/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2012/12/http-basic-authentication-against-non.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/561724383130892191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/561724383130892191'/><link rel='alternate' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2012/12/http-basic-authentication-against-non.html' title='HTTP Basic Authentication against Non-Windows Accounts in IIS/ASP.NET (Part 2 – The HTTP Module)'/><author><name>jivangoyal</name><uri>http://www.blogger.com/profile/12853371042810428434</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2173981707919944244.post-8872235622217374493</id><published>2012-08-12T00:27:00.000-07:00</published><updated>2012-08-12T00:28:14.617-07:00</updated><title type='text'>ActionResult Vs ViewResult</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
1. ActionResult is an abstract class, and it&#39;s base class for ViewResult class.&lt;br /&gt;
2. In MVC framework, it uses ActionResult class to reference the object your action method returns. And invokes ExecuteResult method on it.&lt;br /&gt;
3. It&#39;s usually a good practice to have your method return a more specific class. So if you are sure that your action method will return some view page, you can use ViewResult. But if your action method may have different behavior, like either render a view or perform a redirection. You can use the more general base class ActionResult as the return type.&lt;br /&gt;
4. You can absolutely use specific return types, even though most examples on the web seems to return the ActionResult. The only time I would return the ActionResult class is when different paths of the action method returns different subtypes.&lt;br /&gt;
5.&lt;br /&gt;
&lt;br /&gt;
6. Steven Sanderson also recommends returning specific types in his book Pro ASP.NET MVC Framework. Take a look at the quote below:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&quot;This action method specifically declares that it returns an instance of ViewResult. It would work just the same if instead the method return type was ActionResult (the base class for all action results). In fact, some ASP.NET MVC programmers declare all their action methods as returning a nonspecific ActionResult, even if they know for sure that it will always return one particular subclass. However, it&#39;s a well-established principle in object-oriented programming that methods should return the most specific type they can (as well as accepting the most general parameter types they can). Following this principle maximizes convenience and flexibility for code that calls your method, such as your unit tests.&quot;&lt;/i&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetmvc3.blogspot.com/feeds/8872235622217374493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2012/08/actionresult-vs-viewresult.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/8872235622217374493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/8872235622217374493'/><link rel='alternate' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2012/08/actionresult-vs-viewresult.html' title='ActionResult Vs ViewResult'/><author><name>jivangoyal</name><uri>http://www.blogger.com/profile/12853371042810428434</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2173981707919944244.post-5237561895149959733</id><published>2012-08-11T23:56:00.000-07:00</published><updated>2012-08-12T00:19:46.024-07:00</updated><title type='text'>ViewResult</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
ViewResult derives from ActionResult.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetmvc3.blogspot.com/feeds/5237561895149959733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2012/08/viewresult.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/5237561895149959733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/5237561895149959733'/><link rel='alternate' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2012/08/viewresult.html' title='ViewResult'/><author><name>jivangoyal</name><uri>http://www.blogger.com/profile/12853371042810428434</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2173981707919944244.post-1236823264391366044</id><published>2012-08-11T23:53:00.001-07:00</published><updated>2012-08-12T00:20:15.627-07:00</updated><title type='text'>ActionResult types available</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;ActionResult&lt;/b&gt;&lt;br /&gt;
The action result is a very generic return value for an action. This is because it is the abstract base class for other types of actions. It is actually a very simple class having only one method that needs implementing.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre id=&quot;codeSnippet&quot; style=&quot;background-color: #f4f4f4; border-style: none; direction: ltr; font-family: &#39;Courier New&#39;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 512px;&quot;&gt;&lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;class&lt;/span&gt; ActionResult
{
    &lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;abstract&lt;/span&gt; &lt;span style=&quot;color: blue; margin: 0px; padding: 0px;&quot;&gt;void&lt;/span&gt; 
        ExecuteResult(ControllerContext context);
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;Inheriting from the ActionResult are the following classes:&lt;br /&gt;
&lt;br /&gt;
ContentResult&lt;br /&gt;
EmptyResult&lt;br /&gt;
FileResult&lt;br /&gt;
HttpStatusCodeResult&lt;br /&gt;
JavaScriptResult&lt;br /&gt;
RedirectResult&lt;br /&gt;
RedirectToRouteResult&lt;br /&gt;
ViewResultBase&lt;br /&gt;
&lt;br /&gt;
These are the classes that inherit from ActionResult indirectly:&lt;br /&gt;
&lt;br /&gt;
FileContentResult&lt;br /&gt;
FilePathResult&lt;br /&gt;
FileStreamResult&lt;br /&gt;
HttpNotFoundResult&lt;br /&gt;
HttpUnauthorizedResult&lt;br /&gt;
PartialViewResult&lt;br /&gt;
ViewResult&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ActionResult is an abstract class that can have several subtypes:&lt;br /&gt;
&lt;br /&gt;
a) ViewResult - Renders a specifed view to the response stream&lt;br /&gt;
&lt;br /&gt;
b) PartialViewResult - Renders a specifed partial view to the response stream&lt;br /&gt;
&lt;br /&gt;
c) EmptyResult - An empty response is returned&lt;br /&gt;
&lt;br /&gt;
d) RedirectResult - Performs an HTTP redirection to a specifed URL&lt;br /&gt;
&lt;br /&gt;
e) RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data&lt;br /&gt;
&lt;br /&gt;
f) JsonResult - Serializes a given ViewData object to JSON format&lt;br /&gt;
&lt;br /&gt;
g) JavaScriptResult - Returns a piece of JavaScript code that can be executed on the client&lt;br /&gt;
&lt;br /&gt;
h) ContentResult - Writes content to the response stream without requiring a view&lt;br /&gt;
&lt;br /&gt;
i) FileContentResult - Returns a fle to the client&lt;br /&gt;
&lt;br /&gt;
j) FileStreamResult - Returns a fle to the client, which is provided by a Stream&lt;br /&gt;
&lt;br /&gt;
k) FilePathResult - Returns a fle to the client&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspdotnetmvc3.blogspot.com/feeds/1236823264391366044/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2012/08/actionresult-types-available.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/1236823264391366044'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2173981707919944244/posts/default/1236823264391366044'/><link rel='alternate' type='text/html' href='http://aspdotnetmvc3.blogspot.com/2012/08/actionresult-types-available.html' title='ActionResult types available'/><author><name>jivangoyal</name><uri>http://www.blogger.com/profile/12853371042810428434</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>