views:

22

answers:

1

I'm recieving the following error message,

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.

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

(This is the inner exception...)

Stack Trace

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)

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"); %>

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");
        }

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)

Any suggestions?

A: 

Fixed: (I dont know why its fixed though)

The RenderAction() Method is below

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

Removing the HttpGet Attribute has resolved the issue.

        public ActionResult RenderMenu()
        {
            //Do Stuff
        }

Would love to know why?

Pino
because if you have the Get Attribute, it would only allow get requests. but if there is a post request it cannot find the method.what i think is, if its success, you redirect to another action (with get) but when its failed, it should display the post request, therefore searching for a menu method accepting post.
cRichter
@cRichter - Thanks :)
Pino
@cRichter beat me to it :)
Andi