tags:

views:

36

answers:

1

I have a controller called Parameters which allows some parameters common to my object model to be edited/viewed. Creating/viewing is performed using a couple of partial views - ShowParameters.ascx and CreateParameters.ascx.

I have a number of other controllers that all use ShowParameters.ascx to show their related Parameters. That works fine.

However, I have a problem with my CreateParameters.ascx partial view. It calls an action named CreateParameter in my Parameters controller to create the parameter. My problem is, I would like it to return to the previous controller and show the Index view for that controller, so that the user can see that the parameter has been created.

How can my Parameters controller determine which controller it should return to?

Thanks,

Tubby

+1  A: 

You could pass an additional returnUrl parameter to your CreateParameter action so that it will redirect to this given url. And in your CreateParameters.ascx partial view you could pass the current controller name and action when you construct the link.

Another option would be to always redirect to the Request.UrlReferrer inside your CreateParameter action.

Darin Dimitrov