views:

460

answers:

1

Hello,

I have an action-method in a controller that takes requests coming from a variety of different views.

It is somewhat of a utility method and I simply want it to accept the parameters it is given - do something - and then refresh the view that sent the request.

Right now, the only way I see to do this is by having the method figure out what view sent it the info and do a:

return RedirectToAction("method", "controller");

For each possibility (or something similar to that).

Is there a more general way I can make my method just re-render the current view without having to explicitly identify it?

-Thanks

+1  A: 

Your best bet is to use jQuery to post the data then utilize the results as you see fit. Otherwise you can pass in the action/controller name in the post and use them dynamically to redirect.

Andrew
I was hoping to not have to use jQuery and just rely on the MVC framework to do this since it feels like a somewhat common scenario.As to passing in the action/controller name, that might be a viable option except that many of the view's posting to this method are partial views generated from action methods, so that wouldn't always work.I'd have to kept track of the parent controller/view in each of the partials which is still the same solution as my original problem.
mrkcsc
I did some more digging and I think that indeed passing the controller/action in the post is my only option. I get them using something like:ViewContext.RouteData.GetRequiredString("action")
mrkcsc