简体   繁体   中英

Redirecting to a page using mvc

I have the first method below contained in a dll. I decided to extend it so that I can have control over which page to redirect to. At the moment when I pass a returnUrl nothing happens. The page just returns to the view where I entered values.

? I want to be able to redirect to a page that resides in this path /Views/Rental/Index How can I achieve that?

            [HttpPost]   
                public virtual ActionResult CreateAccount(CreateNewAccountInfo createNewAccountInfo, WebSite webSite, string returnUrl)
                {
                  if (this._accountManager.UserNameAlreadyExists(createNewAccountInfo.UserName))
                    this.ModelState.AddModelError("CreateNewAccountInfo", ErrorMessageProvider.CreateNewAccountInfo_UserName_AlreadyExists);

                  if (this.ModelState.IsValid)
                  {
                    this._accountManager.CreateNewAccount(createNewAccountInfo);        
                    return this.RedirectToReturnUrl(returnUrl);
                  }
                  else
                  {
                    SignIn1ViewModel signIn1ViewModel = this.CreateSignIn1ViewModel(webSite, returnUrl);
                    this.SetupGuestCheckout(webSite, returnUrl, signIn1ViewModel);
                    return (ActionResult) this.View(signIn1ViewModel.WebPage.ViewName, (object) signIn1ViewModel);
                  }
                }


             public override ActionResult CreateAccount(CreateNewAccountInfo createNewAccountInfo, WebSite webSite, string returnUrl)
                    {
                        returnUrl = "../Views/Rental/Index";
                        base.CreateAccount(createNewAccountInfo,webSite,returnUrl);

                        return base.CreateAccount(createNewAccountInfo, webSite, returnUrl);            

                    }

您可以使用ASP.NET MVC约定:

RedirectResult("http://www.google.com");

关于什么:

return RedirectToAction("Index", "Rental");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM