Noob
Noob

Reputation:

ASP.NET MVC - POSTing to another page?

This might be a stupid question...

I have a view which posts back to the controller. I want the controller to now POST to another page with certain parameters instead of sending a 300(Redirect) to the browser? I want to persist a value which I don't want to output int he query string.

Upvotes: 0

Views: 511

Answers (2)

tvanfosson
tvanfosson

Reputation: 532495

I'd suggest using the Redirect and taking advantage of TempData to store the value you don't want included in the query string as a better solution unless the method is in the same controller and you don't care about the Url. If it's in the same controller, you could simply call the method from the current action. If you use TempData, you'll run into some problems with refreshes, but if that's an issue you could store the value in the Session so that it's available longer term.

Upvotes: 1

John Hoven
John Hoven

Reputation: 4085

Can you use a Server.Transfer? You can set your parameters in the HttpContext.Items collection or use values from the previous page.

Upvotes: 1

Related Questions