开发者

asp.net mvc, wrong function being fired. - EDITED

I have master page that has this control that accepts Post verb. My LogOn page is also tied to the master page. When I enter wrong username/password, method of that control that accepts verb also gets fired along with the method to accept username password.

This is on HomeConroller:

 [ActionName("ControlTemp"), AcceptVerbs(HttpVerbs.Post)]
        public ActionResult ControlTemp(TempClass temp)
        {
           return PartialView("ControlTemp"); 
        }

This is on AccountController:

[AcceptVerbs(HttpVerbs.Post)]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
            Justification = "Needs to take same parameter type as Controller.Redirect()")]
        public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
        {

            if (!ValidateLogOn(userName, password))
            {
                return View();
            }

            FormsAuth.SignIn(userName, rememberMe);
            if (!String.IsNullOrEmpty(returnUrl))
            {
                return Redirect(returnUrl);
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }
        }

Now, why do you think things are being posted to ControlTemp too?

EDIT: This is how I am referring to ControlTemp control on masterpage.

            <div id = "divControlTemp">  <% Html.RenderAction("ControlTemp", "Home"); %></div> 

So after watching debugger, I saw it returns View() if username/password is invalid. It then hits the divControlTemp control, but instead of firing public ActionResult ControlTemp(), it fires

[ActionName("ControlTemp"), AcceptVerbs(HttpVerbs.Post)]
            public ActionResult ControlTemp(TempClass temp)

and that is all I can see from the debugger. So my question is why do you think it thinks it is a post? Is 开发者_JS百科it because the reurn View() was called from a method that was accepting Post verb?


If your question is "can a single http requests fire two separate action methods", the answer is no. Unless of course there is a redirect from one action method to the other or one of the methods calls the other directly. If there are redirections, you can see them in the Firebug console.

But frankly, if this was my software, I'd simply fire up the debugger and see what's going wrong. It shouldn't be too difficult to spot the problem this way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜