Asp.Net MVC:子请求的执行失败.请检查InnerException以获取更多信息 [英] Asp.Net MVC : Execution of the child request failed. Please examine the InnerException for more information

查看:41
本文介绍了Asp.Net MVC:子请求的执行失败.请检查InnerException以获取更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误消息,

公共操作方法"RenderMenu"在控制器上找不到"Web.Controllers.SiteController".

A public action method 'RenderMenu' was not found on controller 'Web.Controllers.SiteController'.

但是此操作确实存在并且控制器确实存在(因为它在站点上的任何地方都有效),我查看了内部异常.

However this action DOES exist and the controller does exist (As it work everywhere on the site) I looked at the inner exception.

执行子请求失败.请检查InnerException是否更多信息.

Execution of the child request failed. Please examine the InnerException for more information.

(这是内部异常...)

(This is the inner exception...)

堆栈跟踪

在System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap [TResult](Func`1func)在System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler处理程序,TextWriter编写器,布尔值reserveForm,布尔值setPreviousPage,VirtualPath路径,VirtualPathfilePath,字符串physPath,异常错误,字符串queryStringOverride)

at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func) at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)

现在,我们拥有一个带有动态菜单系统的网站设置,因此我们在通用控制器上使用RenderAction()来构建此菜单系统.

Now, we have a website set-up with a dynamic menu system so we are using RenderAction() on a generic controller to build this menu system up.

<% Html.RenderAction("RenderMenu", "Site"); %>

此调用是从MasterPage进行的,并且可以正常工作,直到出现类似这样的验证错误为止,

This call is made from the MasterPage and it works fine until there was a validation error like so,

 [HttpPost]
        public ActionResult Register(UserModel UserToAdd)
        {
            if(!ModelState.IsValid)
            {
                return View(UserToAdd);
            }
            //Run some validation
            if (_UserService.DoesEmailExist(UserToAdd.EMail))
            {
                TempData["error"] = "Email Address Already in use!";
                return View(UserToAdd);
            }

            //Add the user

            TempData["info"] = "User Added - " + UserO.ID;
            return View("Success");
        }

这是一个新用户,它可以正常工作,但是如果有人输入已经存在的电子邮件,则会出现上述错误.此RenderAction方法可在整个网站上使用(这是我们添加的第一个表格)

It works fine when there this is a new user, but if someone enters an email that already exist we get the above error. THis RenderAction Method works all over the site (This is the first form we have added)

有什么建议吗?

推荐答案

固定:

RenderAction()方法在下面

The RenderAction() Method is below

        [HttpGet]
        public ActionResult RenderMenu()
        {
            //Do Stuff
        }

删除HttpGet属性已解决该问题.

Removing the HttpGet Attribute has resolved the issue.

        public ActionResult RenderMenu()
        {
            //Do Stuff
        }

想知道为什么吗?

这篇关于Asp.Net MVC:子请求的执行失败.请检查InnerException以获取更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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