redirecttoaction

RedirectToAction between areas?

回眸只為那壹抹淺笑 提交于 2019-12-17 15:10:27
问题 Is there a way to redirect to a specific action/controller on a different Area? 回答1: Did you try this?: return RedirectToAction("action", "controller", new { area = "area" }); 回答2: Your answer was helpful to me. Just wanted to add below: If you want to redirect from one area to another area, above code works well. And, if you want to redirect from one area to a controller/view which is not there in the area folder (i.e. in most cases, your front end), you can specify area = "". i.e. return

301 redirect with ? (question mark) not working in htacces

纵然是瞬间 提交于 2019-12-13 04:34:54
问题 This is probably an easy question, but we can not find why the 301 is not working. When we have a url with a question mark the 301 redirect in our .htacces is not working. For example: /order/order.html?AddID=1078&Rand=666171759380936096 so: Redirect 301 /order/order.html?AddID=1078&Rand=666171759380936096 http://www.domain.nl In our webmaster tools we have 8000 url's with the same structure /order/order.html?AddID=.... that say 404 not found. We want to 301 redirect them to the homepage, but

Passing a model into RedirectToAction()

久未见 提交于 2019-12-12 10:53:44
问题 I'm curious how this works. In MVC you can call View() and pass a model as a parameter, but RedirectToAction (one of its incarnations at least) takes a 'routeValues' object, which appears to be the closest match. If your model is passed in this parameter will that model type be available in the subsequent action method? Or are there caveats involved that might prevent accurate translation in some circumstances? 回答1: If you need to pass in some-what complex objects to an action after a

jQuery preventing RedirectToAction from working?

痞子三分冷 提交于 2019-12-11 08:14:22
问题 I'm trying to redirect the user if they login successfully but the code I have on my page seems to be preventing the redirection from working. If I remove the jQuery below the redirection works. Can somebody tell me tell me if there's something I'm doing wrong? Thanks I have the following Action: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Login(User user) { var myErrors = new Dictionary<string, string>(); try { if (ModelState.IsValid) { if (userRepository.ValidUser(user)) { return

Session State is erased after calling RedirectToAction() in ASP.NET MVC 3

微笑、不失礼 提交于 2019-12-11 05:58:32
问题 I use a simple sequences: Set a Session State in [HttpGet] method. Redirect to another action using RedirectToAction() in [HttpPost] method. Want to get the value of that Session State, in the destination. Problem: If user hits "submit" button on my "Table" view, all the data inside session got cleared and I can't get them in the destination action (which is "Table"). Here is the code: [HttpGet] public ActionResult Edit(string TableName, int RowID, NavigationControl nav) { if (nav != null)

How to use RedirectToAction to redirecto to a position in the page?

一个人想着一个人 提交于 2019-12-11 02:57:30
问题 I am using MVC4, C# and visual studio ultimate 2013 in a project. I am redirecting a user to an index page after submiting a form. However, this webpage has 2 tabs, and I want to redirect the user to the second tab, instead of the first one. I have a Controller called Material , with an Index action, which sends the user to the Index View. public ActionResult Index() { return View(); } This View is made of two partial Views, _Materials and _Packages . @{ ViewBag.Title = "Index"; } <div class=

RedirectToAction not working when called by jQuery?

空扰寡人 提交于 2019-12-11 02:54:33
问题 I am trying to call an action method by jQuery, and got help with passing parameters here: Calling action method in MVC with jQuery and parameters not working . However, even though the parameters are sent correctly now, in the action method I need to redirect (passing on those same parameters) to another action method. In the debugger I can see that the redirect is carried out, and the parameters are still there, but the View returned doesn't update accordingly... Is there some problem with

Problems with RedirectToAction MVC2 - Cannot implicitly convert type 'System.Web.Mvc.RedirectToRouteResult' to 'System.Web.Mvc.ViewResult'

只谈情不闲聊 提交于 2019-12-10 12:31:55
问题 I am receiving this error when trying to use RedirectToAction, can anyone offer any advice on why this could be occuring, ive used this before without any problems, i must be missing something. Cannot implicitly convert type 'System.Web.Mvc.RedirectToRouteResult' to 'System.Web.Mvc.ViewResult' [HttpPost] public ViewResult Edit(Customer customer) { if (ModelState.IsValid) { customersRepository.SaveCustomer(customer); TempData["message"] = customer.CustomerName + " has been saved."; return

Render view to string followed by redirect results in exception

夙愿已清 提交于 2019-12-09 23:39:10
问题 So here's the issue: I'm building e-mails to be sent by my application by rendering full view pages to strings and sending them. This works without any problem so long as I'm not redirecting to another URL on the site afterwards. Whenever I try, I get "System.Web.HttpException: Cannot redirect after HTTP headers have been sent." I believe the problem comes from the fact I'm reusing the context from the controller action where the call for creating the e-mail comes from. More specifically, the

ASP.NET MVC - Pass current GET params with RedirectToAction

╄→尐↘猪︶ㄣ 提交于 2019-12-09 23:33:50
问题 I'm looking for a way to use RedirectToAction while passing along the current request's GET parameters. So upon going to: http://mydomain.com/MyController/MyRedirectAction?somevalue=1234 I would then want to redirect and persist somevalue with the a redirect without having to explicitly build a route dictionary and explicitly setting somevalue public ActionResult MyRedirectAction() { if (SomeCondition) RedirectToAction("MyAction", "Home"); } The redirected action could then use somevalue if