हाय मैं एक कस्टम प्राधिकरण फिल्टरASP.NET IAuthorizationFilter OnAuthorization
//The Authourization attribute on a controller
public class CustomAdminAuthorizationFilter : IAuthorizationFilter
{
private readonly IAuthentication _authentication;
public SageAdminAuthorizationFilter(IAuthentication authentication)
{
_authentication = authentication;
}
public void OnAuthorization(AuthorizationContext filterContext)
{
bool result = _authentication.Authorize(filterContext.HttpContext);
}
}
लागू करने के लिए आप OnAuthorization मैं वापस एक परिणाम है कि झूठी का सच है पाने पर देख सकते हैं कोशिश कर रहा हूँ। मुझे वापस आने के लिए सेट करने की क्या ज़रूरत है जहां से मैं आया था?
संपादित करें:
यह अभी भी मैं इंजेक्षन IAuthetication
this.BindFilter<CustomAdminAuthorizationFilter>(FilterScope.Controller, 0);
Bind<IAuthentication>().To<CustomAuthenticationService>();
तब मैं इतनी के रूप में नियंत्रक में मेरी कार्रवाई को सजाने कर पेज
में लॉग करने के लिए मुझे सीधे फेंक रहा है।
[Authorize]
public ActionResult Index()
{
ViewBag.Title = "Welcome";
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
मेरी web.config इम
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
का उपयोग कर में यह बदला जा सकता है?
किसी भी मदद की सराहना की जाएगी।
आपके प्रश्न का उत्तर का उपयोग करें? – hunter