カスタムセキュリティフレームワークを使用してユーザー権限に基づいてコントロールを無効/有効にしようとしています。コードビハインドファイルでこのコードを使用しようとしています。MVC3アクセスコントロール
protected void OnLoadComplete(object sender, EventArgs e)
{
if ((ViewData[Constants.Permission]).Equals(Security.UserAccess.ReadOnlyAccess))
{
foreach (var control in this.Page.Controls )
{
control.IsReadOnly = true;
}
}
}
ただし、コントロールのIsReadOnlyプロパティは使用できません。これを解決する方法やこれを実現するためのより良い方法はありますか?
---更新---
Controller.cs
[Proxy.AimsAccessLevel]
public ActionResult Edit(int clientId)
{
ClientId = clientId;
//SetClientDetails();
var Selection = new SelectionArgs(clientId, null);
if (Selection.SelectionFlag == null || Selection.SelectionFlag == "N")
Selection.EffectiveDate = new DateTime(DateTime.Now.Year + 1, 1, 1);
return View(Selection);
}
proxy.csです
public class AccessLevel : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
Roles = Constants.AccessLevel.FullEdit + Constants.AccessLevel.ReadOnly.ToString() +
Constants.AccessLevel.RestrictedEdit;
return base.AuthorizeCore(httpContext);
}
}
MVCは、分離コードを持っていません。 MVCやWebFormsを使用していますか? –
私はmvcを使用しています。使用したのは<%@ Page CodeBehind = "Edit.aspx.cs" Title = "" Language = "C#" MasterPageFile = "〜/ Views/Shared/Site.Master" Inherits = "Views.Selection.Edit" %> 私にエラーがありません –