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.

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;
}
}
}