0

I want to change url of host web from provider hosted app. Basically, after completion of some business logic in my provider hosted app, I want to navigate to another page of SharePoint portal (for example the search-center page).

When I do "response.redirect" or "window.location.href" it is loading within the App iframe. I want to load the same page in main window.

Please suggest.

Updating with my logic I have a generic method to get List home page url

public string ListHomePage(ClientContext clientContext, string listName)
        {

            Web spWeb = clientContext.Web;
            clientContext.Load(spWeb, web => web.Url);
            clientContext.ExecuteQuery();

            return TokenHelper.GetAppContextTokenRequestUrl(spWeb.Url, HttpContext.Current.Server.UrlEncode(spWeb.Url + "/Lists/" + listName));
        }

and I am calling following code in App page.

Response.Redirect(ListHomePage(clientContext1, "Test ListName"));

1 Answers1

0

The same can be achieved using below code as the AppPart loads inside a iframe

    string redirectUrl = ListHomePage(clientContext1, "Test ListName");
    string script = "<script type='text/javascript'>window.parent.location.href = '" + redirectUrl + "'; </script>";
    //Here I am using Telerik ScriptManager to execute script
    RadScriptManager.RegisterStartupScript(this, this.GetType(), "Load", script, false);
Santosha Epili
  • 317
  • 2
  • 6