views:

64

answers:

1

my first question is, where do I put this custom extension so that it can be called rather than the default AuthorizeAttribute?

I currently have created a new project that contains all of my business logic within my MVC solution. I have a .cs file within my logic project that contains all of my security classes. I tried adding an extension class to that file and on my controller, it sees the class just fine and intellisense isn't barking at me when I add the attribute, but when I try to compile, I get an error that the type or namespace could not be found. Does the custom attribute need to be housed somewhere special in order to compile?

Second question...could be related to the first: When I'm trying to override the AuthorizeCore method from AuthorizeAttribute, I'm passing in System.Web.HttpContextBase as httpcontext. For some reason visual studio can't resolve System.Web.HttpContextBase. Again this might be related to where I have this class saved in my solution. Or perhaps I need to import a dll somewhere to extend this?

Please advise.

A: 

As far as I am aware the class can be in any class library project as long as you have properly referenced the project in your web site. You might want to try recompiling the project -- it sounds like it's able to find the source files, but the code isn't in the DLL.

You probably need to add in a reference to System.Web.Abstractions to your project. While the "base" classes are in the System.Web namespace, they are found in a different DLL.

tvanfosson
everything is referenced correctly. I tried adding "using System.Web.Abstractions" to my .cs file and it didn't like that. You suggest that I recompile the project...but that's where my problem is, it won't compile. When I added my extended attribute class directly to one of my controller files, it works fine, it's only when I put it in the separate project (in a different namespace) that it fails. As I said, VS sees the class fine and highlights it accordingly on my attribute, but I can't compile and build the solution....
Kyle
Did you add the System.Web.Abstractions DLL reference to the project containing your custom attribute code? It won't compile without it. Once you can get that project to compile, I expect that the rest of the solution will as well.
tvanfosson
ahh...didn't add it as a reference before. I just did and everythign works perfectly! Thanks so much.
Kyle