English 中文(简体)
ASP. NET MVC 2 批准
原标题:ASP.NET MVC 2 Authorization Regex

目前的情况如下:

namespace AzureCCCMVC.Controllers
{
  [Authorize(Roles="Admin")]
  public class AdminController : Controller
  {
     //Stuff
  }
}

我想要做的是,每个客户,例如客户,都可以发挥作用。

   Roles  { "DEMOAdmin", "GOOGAdmin" , "MSFTAdmin" }

并且能够授权客户名称(来自URL)和发挥这一作用

我知道,我正在做解释这一点的可怕工作。 我可以有用户,用户是几个客户的用户,但只有一个用户。

问题回答

我不敢肯定,如果我完全理解你试图做些什么,而是猜测你的方向是错误的。 什么将阻止你从客户和客户所属商店中独立发挥作用:

admin1 -> GOOG admin2 -> MSFT

有了这一信息,就只能使用[Authorize(Roles=“Admin”),并且只显示属于其组织的用户数据:

    [Authorize(Roles="Admin")] 
  public class AdminController : Controller 
  { 
     var data = GetDataForDomain(); //retreive data based on organisation of the user
  } 




相关问题
ASP.Net MVC - Handle Multiple Checkboxes

Ok, I have a role based permission system in place and would like admin s to be able to edit the permissions for each role. To do this I need to load lots of checkboxes, however I m struggling with ...

Entity Framework error when submitting empty fields

VS 2010 Beta 2, .NET 4. In my ASP.NET MVC 2 application, when I submit a form to an action method that accepts an object created by the entity framework, I get the following error: Exception Details:...

ASP.Net MVC Architecture - Location of ViewModels

We have a decent sized MVC project running well at the moment, i ve started to look at some re-factoring and I have a question. At the moment the Data Layer and Service Layer is stored in a seperate ...

ASP.Net MVC Go To Declaration On view

Is there anyway when in an MVC view to right click a function call and get to the declaration? Like you can do in the code behind/controllers

ASP.NET MVC 2 Beta - Default Model Binder

I m experiencing some different behavior after switching from ASP.NET MVC 1.0 to ASP.NET MVC 2 Beta. I checked the breaking changes but it s not clear where the issue lies. The problem has to do with ...

Asp.net MVC Dynamic Menu System

In our current Asp.net MVC application we have 2 menu systems one accross the top and one on the left hand side. Now we have a partial view that renders the menu, however is the only way for this too ...

热门标签