ActionFilter and Authorize Attribute in MVC causing object reference error
<p>I am using <code>MVC4</code> to build <code>ASP.NET</code> application. I am using <code>ActionFilterAttribute</code> and <code>AuthorizeAttribute</code> in my business logic. Following is sample code</p>

<p><strong>Controller Class</strong>    </p>

<pre><code>[SessionExpire]
[AuthorizeSubscription]
public class StoreController : Controller
{
    public ActionResult StoreDetail()
    {
       // My logic goes here
    }

    [AuthorizeProductEdit]
    [HttpGet]
    public ActionResult EditProduct()
    {
       // My logic goes here
    }
</code></pre>

<p>If we look at the code, I have first used <code>SessionExpire</code> attribute that inherit <code>ActionFilterAttribute</code> class, It check if <code>session</code> is valid for current request and do some redirection there. Next, i am checking <code>AuthorizeSubscription</code> attribute that inherit <code>AuthorizeAttribute</code> class. It also do some redirection based on logic written over there.</p>

<p>In <code>EditProduct</code> Action, i have used another <code>AuthorizeAttribute</code>.</p>

<p>If I hit url for <code>StoreDetail</code> Action without making any <code>session</code>, it redirect me to desired page. </p>

<p>But if i hit url for <code>EditProduct</code> Action, It throws me <code>Object Reference error</code>. During debug It first goes into the code for <code>AuthorizeProdcutEdit</code> and there fail for finding <code>Session</code> Null. </p>

<p>Why it is not executing <code>SessionExpire</code> code first and exit from there if found <code>Session</code> Null ?</p>