SharePoint uses Post method to display provider-hosted app in iframe
Classic book example for the simple MVC application doesn't work if you want to display it as provider hosted app in SharePoint! By classic, I mean situation where you have 2 Controller's actions with the same name, but for different HttpMethods: Get and Post. You use "Get" to display information to a user and "Post" to retrieve updated information back from the user.
For example,
EditProduct "Get" action will return some product information, and EditProduct "Post" action will receive updated model from the view and presumably save it to the DB.
It gets tricky with SharePoint - it always sends HttpPost to your Controller, so EditProduct "Post" action gets hit.
The only workaround I found so far (I don't have that extensive experience with MVC as I have with WebForms) is to simply rename EditProduct "Post" action to SaveProduct and explicitly set Form action to "SaveProduct".
For example,
EditProduct "Get" action will return some product information, and EditProduct "Post" action will receive updated model from the view and presumably save it to the DB.
It gets tricky with SharePoint - it always sends HttpPost to your Controller, so EditProduct "Post" action gets hit.
The only workaround I found so far (I don't have that extensive experience with MVC as I have with WebForms) is to simply rename EditProduct "Post" action to SaveProduct and explicitly set Form action to "SaveProduct".
Comments
Post a Comment