As following to this answer I have created an AuthorizeAttribute
class in my projects default namespace. So that the compiler will automatically pick it up instead of MVC's standard one. But it picks System.Web.Mvc.Authorizeattribute
.
If I include my projects namespace, which is using TestIdentitySample;
then the following error was shown
'Authorize' is an ambiguous reference between 'System.Web.Mvc.Authorizeattribute' and 'ProjectDefaultNamespace'
- Please be noted that I do not want to use fully qualified name or namespace alias or other Custome Attributes name.
My AuthorizeAttribute Class
namespace TestIdentitySample
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class AuthorizeAttribute : System.Web.Mvc.AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(System.Web.Mvc.AuthorizationContext filterContext)
{
if (filterContext.HttpContext.Request.IsAuthenticated)
{
filterContext.Result = new System.Web.Mvc.HttpStatusCodeResult((int)System.Net.HttpStatusCode.Forbidden);
}
else
{
base.HandleUnauthorizedRequest(filterContext);
}
}
}
}
I just want that the compiler will automatically pick it up instead of MVC's standard one if it is possible. Thanks in advance for any help.