<location path="request.ashx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Nasıl koddan bu seçeneği alınır?
<location path="request.ashx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Nasıl koddan bu seçeneği alınır?
Yetkilendirme özelliğini kullanmaktan daha iyidir, eğer bir koşul kullanmanın çok daha iyi olacağını düşünüyorum. Kullanıcı aniden Özellikte olarak loginpage yönlendirilir ise
If(User.Identity.IsAuthenticated)
{
If(User.Identity.IsInRole=="admin")
{
return view("Secret");
}
else
{
return view("NotAllowed")
}
}
else
{
return View("NeedAuth");
}
, o web sitesinde bir hata olarak düşünebilirsiniz ama bu şekilde açıkça o kimlik doğrulaması gerekiyor kullanıcıyı söylemek mümkün olacaktır.
Bu deneyin:
public void ProcessRequest(HttpContext context)
{
if (HttpContext.Current.User.Identity.IsAuthenticated == false)
{
context.Response.Redirect("Your Path");
}
}
Eğer MVC kullanıyorsunuz? –
Bu soru hakkında SO: http://stackoverflow.com/questions/10848086/authorize-attribute-in-asp-net-mvc – pix
Umarım bunu araştırırsınız. http://stackoverflow.com/questions/1240552/accessing-authorization-information-in-web-config – Hari