I was wondering how you could scoff at the fact that the controller is decorated with the [Authorize] attribute in MVC3? I am using a custom membership provider. I would like to check that the controller was decorated with an attribute, and you are authorized and what happens when you do not. I am using Moq. Any good suggestions on this ?!
UPDATE: I am currently getting a NullreferenceException saying that "the reference to the object is not set to the instance of the object". This is the same error that was mentioned earlier in this NullReferenceException when using the authorization attribute
This is due to the Authorize attribute. I work under iis and do not use cassini. Does anyone know if this is related to the application pool and user rights. The tests that I have for the authorize attribute will work until this is fixed.
Maybe there is another way to test the Authorize attribute? Thank you very much in advance.
UPDATE2 Therefore, after some extensive research and debugging help from a colleague that I mentioned, to fix the problem with the [Authorize] attribute. This line seems to be missing from the web.config file:
<modules runAllManagedModulesForAllRequests="true">
Oddly enough, this did not cause a problem for another colleague who shared the trunk or beta environment. It only created problems for me locally. This could be due to something in the PAC. In any case, everything is working now.
Thanks.
Tim
source share