MVC Action使IIS访问被拒绝错误 [英] MVC Action giving IIS access denied error

查看:202
本文介绍了MVC Action使IIS访问被拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常奇怪的问题,它只影响我在特定控制器中的一个操作。



此控制器中的所有其他操作都很好,但是当我发布一个特定操作的视图我收到错误:


HTTP错误403.0 - ModSecurity操作您没有
的权限查看此目录或页面。


这使我感到困惑,因为所有视图都以类似方式发布并使用相同的web.config文件。 / p>

我的观点:

 < form action =/ Admin / EditMenusmethod =发布class =form-horizo​​ntal> 
....标准表单控件在这里.....
< / form>



我的控制器:

  [HttpPost] 
public ActionResult EditMenus(string mondayWeek1RegularDescription,
string mondayWeek1RegularCost,
string mondayWeek1VegetarianDescription,
string mondayWeek1VegetarianCost,
string mondayWeek1NocarbDescription,
string mondayWeek1NocarbCost,
string mondayWeek1KiddiesDescription,
string mondayWeek1KiddiesCost,
string tuesdayWeek1RegularDescription,
string tuesdayWeek1RegularCost,
string tuesdayWeek1VegetarianDescription,
string tuesdayWeek1VegetarianCost,
string tuesdayWeek1NocarbDescription,
string tuesdayWeek1NocarbCost,
string tuesdayWeek1KiddiesDescription,
string tuesdayWeek1KiddiesCost,
string wednesdayWeek1RegularDescriptio n,
string wednesdayWeek1RegularCost,
string wednesdayWeek1VegetarianDescription,
string wednesdayWeek1VegetarianCost,
string wednesdayWeek1NocarbDescription,
string wednesdayWeek1NocarbCost,
string wednesdayWeek1KiddiesDescription,
string wednesdayWeek1KiddiesCost ,
string thursdayWeek1RegularDescription,
string thursdayWeek1RegularCost,
string thursdayWeek1VegetarianDescription,
string thursdayWeek1VegetarianCost,
string thursdayWeek1NocarbDescription,
string thursdayWeek1NocarbCost,
string thursdayWeek1KiddiesDescription,
string thursdayWeek1KiddiesCost,
string fridayWeek1RegularDescription,
string fridayWeek1RegularCost,
string fridayWeek1VegetarianDescription,
strin g fridayWeek1VegetarianCost,
string fridayWeek1NocarbDescription,
string fridayWeek1NocarbCost,
string fridayWeek1KiddiesDescription,
string fridayWeek1KiddiesCost,
string mondayWeek2RegularDescription,
string mondayWeek2RegularCost,
string mondayWeek2VegetarianDescription,
string mondayWeek2VegetarianCost,
string mondayWeek2NocarbDescription,
string mondayWeek2NocarbCost,
string mondayWeek2KiddiesDescription,
string mondayWeek2KiddiesCost,
string tuesdayWeek2RegularDescription,
string tuesdayWeek2RegularCost ,
string tuesdayWeek2VegetarianDescription,
string tuesdayWeek2VegetarianCost,
string tuesdayWeek2NocarbDescription,
string tuesdayWeek2NocarbCost,
string tuesdayW eek2KiddiesDescription,
string tuesdayWeek2KiddiesCost,
string wednesdayWeek2RegularDescription,
string wednesdayWeek2RegularCost,
string wednesdayWeek2VegetarianDescription,
string wednesdayWeek2VegetarianCost,
string wednesdayWeek2NocarbDescription,
string wednesdayWeek2NocarbCost ,
string wednesdayWeek2KiddiesDescription,
string wednesdayWeek2KiddiesCost,
string thursdayWeek2RegularDescription,
string thursdayWeek2RegularCost,
string thursdayWeek2VegetarianDescription,
string thursdayWeek2VegetarianCost,
string thursdayWeek2NocarbDescription,
string thursdayWeek2NocarbCost,
string thursdayWeek2KiddiesDescription,
string thursdayWeek2KiddiesCost,
string fridayWeek2RegularDescription,
string fridayWeek2RegularCost,
string fridayWeek2VegetarianDescription,
string fridayWeek2VegetarianCost,
string fridayWeek2NocarbDescription,
string fridayWeek2NocarbCost,
string fridayWeek2KiddiesDescription,
string fridayWeek2KiddiesCost,
string week1StartDate,
string week2StartDate,
string orderBy,
string menuStart,
string menuEnd
){
...标准控制发布到model ...
return View();
}



我的错误说,它必须是相关的IIS但事实上,其他动作在同一个控制器工作得很好,它只是这一个告诉我别的东西....就像我说的这个本地工作正常,但在服务器上提供了错误。


解决方案

正如@Sippy所说,问题在于ModSecurity中的规则,托管公司没有正确配置。



再次感谢。



我今天也了解了视图模型lol


I have a very strange issue that is affecting only one of my actions in a specific controller.

All other actions in this controller post just fine, but when I post the view of one particular action I get the error:

HTTP Error 403.0 - ModSecurity Action You do not have permission to view this directory or page.

This confuses me as all views post in a similar fashion and use the same web.config files.

My view:

<form action="/Admin/EditMenus" method="Post" class="form-horizontal">
....standard form controls in here.....
</form>

My controller:

[HttpPost]
public ActionResult EditMenus(string mondayWeek1RegularDescription,
            string mondayWeek1RegularCost,
            string mondayWeek1VegetarianDescription,
            string mondayWeek1VegetarianCost,
            string mondayWeek1NocarbDescription,
            string mondayWeek1NocarbCost,
            string mondayWeek1KiddiesDescription,
            string mondayWeek1KiddiesCost,
            string tuesdayWeek1RegularDescription,
            string tuesdayWeek1RegularCost,
            string tuesdayWeek1VegetarianDescription,
            string tuesdayWeek1VegetarianCost,
            string tuesdayWeek1NocarbDescription,
            string tuesdayWeek1NocarbCost,
            string tuesdayWeek1KiddiesDescription,
            string tuesdayWeek1KiddiesCost,
            string wednesdayWeek1RegularDescription,
            string wednesdayWeek1RegularCost,
            string wednesdayWeek1VegetarianDescription,
            string wednesdayWeek1VegetarianCost,
            string wednesdayWeek1NocarbDescription,
            string wednesdayWeek1NocarbCost,
            string wednesdayWeek1KiddiesDescription,
            string wednesdayWeek1KiddiesCost,
            string thursdayWeek1RegularDescription,
            string thursdayWeek1RegularCost,
            string thursdayWeek1VegetarianDescription,
            string thursdayWeek1VegetarianCost,
            string thursdayWeek1NocarbDescription,
            string thursdayWeek1NocarbCost,
            string thursdayWeek1KiddiesDescription,
            string thursdayWeek1KiddiesCost,
            string fridayWeek1RegularDescription,
            string fridayWeek1RegularCost,
            string fridayWeek1VegetarianDescription,
            string fridayWeek1VegetarianCost,
            string fridayWeek1NocarbDescription,
            string fridayWeek1NocarbCost,
            string fridayWeek1KiddiesDescription,
            string fridayWeek1KiddiesCost,
            string mondayWeek2RegularDescription,
            string mondayWeek2RegularCost,
            string mondayWeek2VegetarianDescription,
            string mondayWeek2VegetarianCost,
            string mondayWeek2NocarbDescription,
            string mondayWeek2NocarbCost,
            string mondayWeek2KiddiesDescription,
            string mondayWeek2KiddiesCost,
            string tuesdayWeek2RegularDescription,
            string tuesdayWeek2RegularCost,
            string tuesdayWeek2VegetarianDescription,
            string tuesdayWeek2VegetarianCost,
            string tuesdayWeek2NocarbDescription,
            string tuesdayWeek2NocarbCost,
            string tuesdayWeek2KiddiesDescription,
            string tuesdayWeek2KiddiesCost,
            string wednesdayWeek2RegularDescription,
            string wednesdayWeek2RegularCost,
            string wednesdayWeek2VegetarianDescription,
            string wednesdayWeek2VegetarianCost,
            string wednesdayWeek2NocarbDescription,
            string wednesdayWeek2NocarbCost,
            string wednesdayWeek2KiddiesDescription,
            string wednesdayWeek2KiddiesCost,
            string thursdayWeek2RegularDescription,
            string thursdayWeek2RegularCost,
            string thursdayWeek2VegetarianDescription,
            string thursdayWeek2VegetarianCost,
            string thursdayWeek2NocarbDescription,
            string thursdayWeek2NocarbCost,
            string thursdayWeek2KiddiesDescription,
            string thursdayWeek2KiddiesCost,
            string fridayWeek2RegularDescription,
            string fridayWeek2RegularCost,
            string fridayWeek2VegetarianDescription,
            string fridayWeek2VegetarianCost,
            string fridayWeek2NocarbDescription,
            string fridayWeek2NocarbCost,
            string fridayWeek2KiddiesDescription,
            string fridayWeek2KiddiesCost,
            string week1StartDate,
            string week2StartDate,
            string orderBy,
            string menuStart,
            string menuEnd
            ){
...standard control posting to model...
return View();
}

The error to me says it must be IIS related but the fact that other actions in the same controller work just fine and it's just this one tells me something else....Like I said this works locally fine but on server gives the error.

解决方案

As @Sippy suggested the issue was with rules in ModSecurity that the hosting company did not configure correctly.

Thanks again.

I also learnt about view models today lol

这篇关于MVC Action使IIS访问被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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