在MVC 4中使用基本控制器 [英] Use of Base controller in MVC 4

查看:62
本文介绍了在MVC 4中使用基本控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friends,



我正在开发一个复杂的Asp.net MVC 4应用程序,我必须从数据库管理角色和权限。我有一个屏幕,我可以选择一个动作并允许它发挥作用。我可以在几个模块上做同样的事情。现在我遇到一个问题,即主要操作表中没有列出其他一些操作(数据库中的表,我添加了大部分操作,如索引,编辑,详细信息,删除等)。因此,每当我需要通过ajax调用访问控制器的新操作/功能时,我必须在表中添加我不想要的,因为这是一种帮助方法。



我创建了一个BaseController,我在其中检查基于roleid,action name和module name的权限。基本控制器不允许任何未添加到操作表的方法,并且没有与之关联的权限。有没有办法我可以允许其他方法没有检查基本控制器或基本控制器应该知道这是一种帮助方法就像Childaction。



请建议。



谢谢,

Jagjot

Hello Friends,

I am working on a complex Asp.net MVC 4 application where I have to manage role and permissions from database. I have a screen where I can select an action and allow that to role. I can do same thing on several modules. Now I have an issue that there are some other actions which are not listed in main actions table (a table in database where I have added most of the actions like Index, Edit, Details, Delete etc). So whenever a new action/function is added to controller which I need to access via ajax call, I have to add that in table which I dont want to, because that is a helper kind of method.

I have created a BaseController in which I am checking the permissions based on roleid, action name and module name. The base controller does not allow any method which is not added to actions table and has not permission associated with that. Is there any way I can allow other methods without checking in base controller or the base controller should know that this is a kind of helper method just like Childaction.

Please suggest.

Thanks,
Jagjot

推荐答案

请看下面的网址使用基本控制器的好例子

MVC Basic站点:第4步 - 使用AJAX,JSON,jQuery,LINQ和序列化在MVC 4.0中进行jqGrid集成[ ^ ]
Please see below url of good example of using base controller
MVC Basic Site: Step 4 – jqGrid Integration in MVC 4.0 using AJAX, JSON, jQuery, LINQ, and Serialization[^]


我修改了一些权限并检查了后端所需的操作而不是检查所有行动。如果修复了我遇到的问题。
I modified some permissions stuff and checked only required actions in backend rather than checking all actions. If fixed the issue I was having.


这篇关于在MVC 4中使用基本控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆