redirecttoaction

How do you RedirectToAction using POST instead of GET?

When you call RedirectToAction within a Controller, it automatically redirects using an HTTP GET. How do I explicitly tell it to use an HTTP POST? I have an Action that accepts both GET and POST requests, and I want to be able to RedirectToAction using a POST and send it some values. Like this: this.RedirectToAction("actionname", new ...

Does ASP.NET MVC RC has a strongly typed RedirectToAction method already?

Since I have decided to let RC go while staying with Beta for now, I have no way of knowing whether there has been some progress in this area. Who has tried it, are there strongly typed RedirectToAction and maybe ActionLink in RC? (I know there is some extra stuff in Futures assembly, but the question really refers to the main build). ...

In ASP.NET MVC, preserve URL when return RedirectToAction

I have an action method, and depending on what is passed to it, I want to redirect to another action in another controller. The action and controller names are determined at run time. If I return RedirectToAction(), it will force a redirect and change the URL in the browser. What I would like is something like TransferToAction() tha...

Get filter redirect to action?

RedirectToAction is protected, and we can use it only inside actions. But if I want to Redirect in Filter? public class IsGuestAttribute: ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { if (!Ctx.User.IsGuest) filterContext.Result = (filterContext.Controller as Contro...

RedirectToAction - but I want it to go to http://site.com/controller/action/id?

I'd like to move an asp.net mvc response to http://site.com/emails/list/[email protected] Using RedirectToAction("list", "emails", new { id = "[email protected]"}); takes you to http://site.com/emails/[email protected]. What am I doing wrong? Thanks, Rob ...

Render view to string followed by redirect results in exception

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 belie...

keep viewdata on RedirectToAction

[AcceptVerbs(HttpVerbs.Post)] public ActionResult CreateUser([Bind(Exclude = "Id")] User user) { ... db.SubmitChanges(); ViewData["info"] = "The account has been created."; return RedirectToAction("Index", "Admin"); } This doesnt keep the "info" text in the viewdata after the redirectToAction. How would ...

Rendering a view to a string in MVC, then redirecting -- workarounds?

Hi -- I can't render a view to a string and then redirect, despite this answer from Feb (after version 1.0, I think) that claims it's possible. I thought I was doing something wrong, and then I read this answer from Haack in July that claims it's not possible. If somebody has it working and can help me get it working, that's great (and...

RedirectToAction between areas?

Is there a way to redirect to a specific action/controller on a different Area? ...

Should Rails redirect_to be sending html?

In most frameworks, sending a redirect means setting the HTTP headers and exiting without sending any HTML data back to the browser. However, using Firebug I see that Rails is not following this convention: def update @phone_number = PhoneNumber.find(params[:id]) if @phone_number.update_attributes(params[:phone_number]) fl...

RedirectToAction Not Loading Correct View

Hello, This is a weird one. Probably painfully obvious. :D I have a View (let's call it View0.aspx) that posts a form to a controller action (let's call it Action1). Action1 runs and then returns RedirectToAction("Action2"), which in turn returns View("View2"). Running it in the debugger, everything looks great (Action2 breakpoint gets...

Retain jquery tab position after Post action in asp.net mvc

I have a page with jquery tabs in which the user can update their Profile, Password, General in each tab. When a user update the details in "General" tab, the post action will be called and it should retain the "General" tab back. It can be accessed directly by calling like http://localhost:8742/User/Settings/10#General. In the url 10...

Route not getting resolved.

I want clean URLs and have defined two routes: routes.MapRoute( "Search", "Search", new { controller = "Search", action = "SearchPanel" } ); routes.MapRoute( "SearchResults", "Search/{content}", new { controller = "Search", action = "Search", content = string.Empty, query = string.Empty, index = 0 } ); then I h...

Asp.NET MVC strong typed controllers

I saw somewhere code like this: return View(x=>x.List()); Instead of return View("List"); What do I need to achieve this ? I'm using Asp.net MVC 2 RC 2 EDIT I do not mean strong typed views Next example return this.RedirectToAction(c => c.Speaker()); ...

MVC 2 RC RedirectToAction woes

Hiya! I have setup a custom route as defined in my global.asax: routes.MapRoute( "Search", "{controller}/{action}/{type}/{searchterm}", new { controller = "Search", action = "Results", type = "", searchterm = "" } ); Now all I want to do it in a controller when data is passed via POST basically go in the form...

How do you link to an action that takes an array as a parameter (RedirectToAction and/or ActionLink)?

I have an action defined like so: public ActionResult Foo(int[] bar) { ... } Url's like this will work as expected: .../Controller/Foo?bar=1&bar=3&bar=5 I have another action that does some work and then redirects to the Foo action above for some computed values of bar. Is there a simple way of specifying the route values with Red...

RedirectToAction and validate MVC 2

Hi, my problem is the View where the user typed, the validation. I have to take RedirectToAction on the site because on the site upload a file. Thats my code. My model class public class Person { [Required(ErrorMessage= "Please enter name")] public string name { get; set; } } My View <%@ Page Title="" Language="C#" MasterPageFil...

MVC2 and MVC Futures causing RedirectToAction issues

I've been trying to get the strongly typed version of RedirectToAction from the MVC Futures project to work, but I've been getting no where. Below are the steps I've followed, and the errors I've encountered. Any help is much appreciated. I created a new MVC2 app and changed the About action on the HomeController to redirect to the Inde...

How to either return JSON or RedirectToAction?

I have an Action Method that I'd either like to return JSON from on one condition or redirect on another condition. I thought that I could do this by returning ActionResult from my method but doing this causes the error "not all code paths return a value" Can anyone tell me what I'm doing wrong? Or how to achieve the desired result? He...

How to redirect to a controller action from a JSONResult method in ASP.NET MVC?

I am fetching records for a user based on his UserId as a JsonResult... public JsonResult GetClients(int currentPage, int pageSize) { if (Session["UserId"] != "") { var clients = clirep.FindAllClients().AsQueryable(); var count = clients.Count(); var results = new PagedList<ClientBO>(clients, currentPage - 1, pag...