I have a view user control that can post form. This control can be used on multiple views. If user enters invalid data i add errors to ModelState - as simple as that. The problem is that i don't know which view/actionresult to return since i don't know from where user post form. Ok, i can get urlreferer - but that does not look nice for me. Any idea?
Asked
Active
Viewed 204 times
1 Answers
1
Pass the info from your parent page to the controller.
<% RenderPartial("MyUserControl", new MyUserControlViewData()
{
// pass parent page info here for user control to redirect to such as
Controller = "Home",
Action = "Index"
// or even better
ParentPath = ((WebFormView)this.ViewContext.View).ViewPath
});

Todd Smith
- 17,084
- 11
- 59
- 78