When using a custom HTTP module and you create a view for a list you get an error saying Cannot complete this action. Please try again.

Published May 01 2019 04:02 PM 284 Views
Microsoft
First published on TECHNET on Feb 18, 2015

This post is a contribution from Aravinda Devagari, an engineer with the SharePoint Developer Support team

When you are using a custom HTTP module with a SharePoint site, you will notice that if you go ahead and create a custom list view you will get an error: “Cannot complete this action.  Please try again.” This is primarily because the HTTP module reads the request body and there is no request body left for the OWSSVR.dll to read. We will find 404 error in IIS.

The only workaround available for this is:

Bypass the HTTP module when the URLs contain OWSSVR.dll, so a simple If statement on the HTTPModule’s Begin request event and check if the request URL contains  “OWSSVR”, if it does, do not read or process the request body. You could use the following snippet of code, to achieve this requirement:

public class CustomModule : IHttpModule
{
public void Init(HttpApplication application)
{
application.BeginRequest += new EventHandler(this.OnBeginRequest);
}
void OnBeginRequest(object sender, EventArgs e)
{
if (HttpContext.Current.Request.Url.AbsolutePath.ToLower().Contains("owssvr.dll"))
{
return;
}
}
}

%3CLINGO-SUB%20id%3D%22lingo-sub-509970%22%20slang%3D%22en-US%22%3EWhen%20using%20a%20custom%20HTTP%20module%20and%20you%20create%20a%20view%20for%20a%20list%20you%20get%20an%20error%20saying%20Cannot%20complete%20this%20action.%20Please%20try%20again.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-509970%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20Feb%2018%2C%202015%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3EThis%20post%20is%20a%20contribution%20from%20Aravinda%20Devagari%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team%3C%2FP%3E%0A%20%20%3CP%3EWhen%20you%20are%20using%20a%20custom%20HTTP%20module%20with%20a%20SharePoint%20site%2C%20you%20will%20notice%20that%20if%20you%20go%20ahead%20and%20create%20a%20custom%20list%20view%20you%20will%20get%20an%20error%3A%20%E2%80%9CCannot%20complete%20this%20action.%26nbsp%3B%20Please%20try%20again.%E2%80%9D%20This%20is%20primarily%20because%20the%20HTTP%20module%20reads%20the%20request%20body%20and%20there%20is%20no%20request%20body%20left%20for%20the%20OWSSVR.dll%20to%20read.%20We%20will%20find%20404%20error%20in%20IIS.%3C%2FP%3E%0A%20%20%3CP%3EThe%20only%20workaround%20available%20for%20this%20is%3A%3C%2FP%3E%0A%20%20%3CP%3EBypass%20the%20HTTP%20module%20when%20the%20URLs%20contain%20OWSSVR.dll%2C%20so%20a%20simple%20If%20statement%20on%20the%20HTTPModule%E2%80%99s%20Begin%20request%20event%20and%20check%20if%20the%20request%20URL%20contains%26nbsp%3B%20%E2%80%9COWSSVR%E2%80%9D%2C%20if%20it%20does%2C%20do%20not%20read%20or%20process%20the%20request%20body.%20You%20could%20use%20the%20following%20snippet%20of%20code%2C%20to%20achieve%20this%20requirement%3A%3C%2FP%3E%0A%20%20%3CP%3Epublic%20class%20CustomModule%20%3A%20IHttpModule%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20public%20void%20Init(HttpApplication%20application)%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20application.BeginRequest%20%2B%3D%20new%20EventHandler(this.OnBeginRequest)%3B%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20void%20OnBeginRequest(object%20sender%2C%20EventArgs%20e)%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20if%20(HttpContext.Current.Request.Url.AbsolutePath.ToLower().Contains(%22owssvr.dll%22))%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20return%3B%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20%7D%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-509970%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TECHNET%20on%20Feb%2018%2C%202015%20This%20post%20is%20a%20contribution%20from%20Aravinda%20Devagari%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team%20When%20you%20are%20using%20a%20custom%20HTTP%20module%20with%20a%20SharePoint%20site%2C%20you%20will%20notice%20that%20if%20you%20go%20ahead%20and%20create%20a%20custom%20list%20view%20you%20will%20get%20an%20error%3A%20%E2%80%9CCannot%20complete%20this%20action.%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Aug 27 2020 03:36 PM
Updated by: