【发布时间】:2014-12-18 09:07:29
【问题描述】:
客户要求我禁用调查模块上的编辑功能,但这仍不清楚。暂时应将其从视图中删除,因此用户无法编辑调查。
所以,我去掉了Index视图上的编辑按钮,但我仍然可以通过地址栏访问编辑页面,例如:http://localhost:1306/Survey/Edit/1。
我无法删除编辑操作和编辑视图,因为要求仍不清楚。有什么办法可以处理这种情况?
【问题讨论】:
客户要求我禁用调查模块上的编辑功能,但这仍不清楚。暂时应将其从视图中删除,因此用户无法编辑调查。
所以,我去掉了Index视图上的编辑按钮,但我仍然可以通过地址栏访问编辑页面,例如:http://localhost:1306/Survey/Edit/1。
我无法删除编辑操作和编辑视图,因为要求仍不清楚。有什么办法可以处理这种情况?
【问题讨论】:
您可以使用NonAction 属性或使用private 方法,两种解决方案都可以:
[NonAction]
public ActionResult Edit()
{
}
private ActionResult Edit()
{
}
【讨论】:
[NoAction] 属性? The type or namespace name 'NoAction' could not be found (are you missing a using directive or an assembly reference?)
NonAction
NonAction 也放入Edit POST Action 中?
通过使用非操作方法,您可以像这样实现这一目标
public ActionResult Edit()
{
// Your Code for doing someThing
}
请使用以下代码代替上述代码。
private ActionResult Edit()
{
// Your Code for doing someThing
}
如果你这样使用意味着你将无法访问 Edit 操作方法。
【讨论】:
private而不是[NonAction]?