How can a SharePoint 2013 App Part initiate a redirect in its parent host web?
We have created a custom AppPart in a provider hosted ASP.NET MVC application.
The App Part contains a search button. If the user clicks the search button inside the AppPart we would like a different SharePoint page to be displayed in the HostWeb.
You cannot do that currently and it would be a bad UX experience I believe. The app part is an Iframe that won't give you access to the hostweb page. AFAIK the only client side "message" that you can send to the container page is to request your app part to be resized but you won't be able to navigate the user to a different page. You can open a new window though.
You can use:
window.top.location.href = "url of SharePoint page"
to redirect the user to the intended page. Note: If the page is part of app web, you might have to pass standardtokens also.
Although this is an old question, I hope this will help someone. The best option is to do the following:
<form action="http://myurl.com/search.aspx" target="_parent"> [Your form] <input type="submit" value="Search" /> </form>
The target="_parent" will cause the redirect to be done in the parent site instead of within the iframe.