0

I have some partial views and corresponding action methods in a controller. I call them using Html.Action("PartialView") helper in some Views. This works fine.

However when i type the url of the action of the partial view into the address bar of my browser, controller sends me the partial view back alone(without any wrapping view or layout). This seems weird. I want my controller to redirect request of actions returning partial view to index action but not Html.Action() helpers

How can i do that?

MOD
  • 1,070
  • 3
  • 19
  • 41
  • There isn't really a reliable way to know for certain what UI originated an HTTP request. Why do you want to do this anyway? What problem is being solved by this? – David Feb 10 '16 at 15:34
  • I just dont want the user see weird views without layout or wrapping view – MOD Feb 10 '16 at 15:38
  • You can't prevent the user from manually modifying their UX. Basically, this is a made-up problem that doesn't really need to be solved. The application presents the UX as intended. If the user chooses to deviate from that and manually make requests for data, that's ok. As long as the authorization is maintained, nothing bad is happening. – David Feb 10 '16 at 15:42
  • @David Becouse of your comment I thought it was not possible. However i found what i need after some search – MOD Feb 17 '16 at 19:26

1 Answers1

0

After some search in the internet i found the answer: link

So what i need was just to redirect the request by checking the ControllerContext.IsChildAction in the specific action.

Community
  • 1
  • 1
MOD
  • 1,070
  • 3
  • 19
  • 41