For a provider hosted app in SharePoint any request to the server must preserve standard SharePoint tockens in query string. I have found a blog that explains how to achieve similar functionality in plain MVC
https://www.danylkoweb.com/Blog/quick-tip-querystrings-with-aspnet-mvc-beginform-FO
In practise, instead of adding another BeginFormQueryString extension to Html object I only copied the extension method on query string
And then added the routevalues to OOB BeginForm method like so:
https://www.danylkoweb.com/Blog/quick-tip-querystrings-with-aspnet-mvc-beginform-FO
In practise, instead of adding another BeginFormQueryString extension to Html object I only copied the extension method on query string
public static
RouteValueDictionary ToRouteValueDictionary(this NameValueCollection collection)
{
var routeValues = new RouteValueDictionary();
foreach (string key in collection)
{
routeValues[key] =
collection[key];
}
return routeValues;
}
And then added the routevalues to OOB BeginForm method like so:
@using (@Html.BeginForm("myAction", "myController", Request.QueryString.ToRouteValueDictionary(), FormMethod.Post))
{
No comments:
Post a Comment