Monday, November 23, 2015

How to fix the navigation issue in SharePoint MVC app.

when we select a MVC project template in the visual studio, it automatically generate the page navigation in the layout page. the following snipet of code will show you the systematically generated code

 <li>@Html.ActionLink("Home", "Index", "Home", null)</li>

in the Sharepoint MVC app implement, if we use the same code as above. when we click on the hyper link.
we will use this error message.



 when we exam the web url.

http://localhost/MySPMVCAppWeb/?Length=4. the SPHostUrl is missing in the url. which is root cause of the above issue.

we simply add SPHostUrl Parameter before the null parameter, will help us solve the above issue and allow user to navigate all pages with the app.

<li>@Html.ActionLink("Home", "Index", "Home", new { SPHostUrl = SharePointContext.GetSPHostUrl(HttpContext.Current.Request).AbsoluteUri }, null)</li>









No comments:

Post a Comment