I am creating an MVC3 web application and I am using knockoutjs. There are two types in the application. SetUpNewCompany and ManageAccount. To set up a new company, the user first enters the account number and clicks on the search. If an account number already exists, the user can click the button to go to the ManageAccount view. In SetUpNewCompanyController, I redirect the RedirectToAction method. However, when the Index2 action is executed in ManageAccount, the view is not displayed. If I type the full URL, a view is displayed.
SetUpNewCompanyController.cs
[HttpPost] public RedirectToRouteResult RedirectToManageAccount(string accountNumber) { return RedirectToAction("Index2", new RouteValueDictionary(new {controller= "ManageAccount", companyId = "7e96b930-a786-44dd-8576-052ce608e38f" })); }
This is called by the function below when the button is pressed.
self.redirectToManageAccount = function () { var accountNumber = "7e96b930-a786-44dd-8576-052ce608e38f"; $.ajax({ type: "POST", url: "/SetUpNewCompany/RedirectToManageAccount", data: { accountNumber: accountNumber }, success: function (data) { }, error: function () { } }); }
ManageAccountController.cs
public ActionResult Index2(String companyId) { var viewModel = new Models.Index(); List<String> compList = new List<String>(); compList.Add("MyCompany"); List<String> usersList = new List<String>(); usersList.Add("User1"); viewModel.Users = usersList; viewModel.Companies = compList; viewModel.CompanyId = companyId; viewModel.Role = "Role1"; return View("ManageAccount",viewModel); }
URL generated
http:
The Firebug console window displays
GET http:
Also, how do I get the url lower than the one that has querystring
http:
source share