Protocol Violation when adding a web reference in VS 2005

January 6, 2009

When adding a Web reference in visual studio 2005, i got the following error:
The server committed a protocol violation. Section=ResponseHeader Detail CR must be followed by LF

There was a proxy server interfering with the request and modifying it. Fortunately in this case, i could remove the proxy server reference completely and it worked fine thereafter.

Problem when restoring site collection in WSS

June 11, 2008

I was preforming a backup and restore in MOSS 2007.  When doing this, i got the following error message:

Your backup is from a different version of Windows SharePoint Services and cannot be restored to a server running the current version. The backup file should be restored to a server with version X

It turns out the script I was using had a bug in it.  If i did it through the command line, i had no issues.  So, in fact the versioning or hotfixes applied to the machines had no effect on the restore operation.

javascript submission of xhtml compliant form

March 13, 2008

Let’s say i have a form to perform a login to another site. With the infrastructure we have here, it reads html from a database, build a page containing a form, plugging in real values for some placeholders and then uses javascript to submit the form.

For example:

<body>
   <form method="POST" action="http://othersite/ssologin.php" name="ssoform">
    <input type="hidden" name="user" value="@username" />
    <input type="hidden" name="pass" value="@password" />
  </form>
  <script type="text/javascript">document.ssoform.submit();</script>
</body>

However, this is not XHTML compliant code. The ‘name’ attribute is deprecated and should be replaced by ‘id’. But in doing so, the javascript does not work anymore and the form doesn’t submit at all. It turns out that the javascript needs to be modified slightly:

<body>
  <form method="POST" action="http://othersite/ssologin.php" id="ssoform">
    <input type="hidden" name="user" value="@username" />
    <input type="hidden" name="pass" value="@password" />
  </form>
  <script type="text/javascript">document.forms.ssoform.submit();</script>
</body>

Storing objects in the .net session in sharepoint

March 5, 2008

In our webparts, we’re storing objects in the ASP.NET Session. Whenever we would set the value in the session, SharePoint would just stop working. It would give an Error page with no reason for the failure.

If i put a string or int in the session, it would work fine, but not our custom objects we’re creating. I played with serialization for a while, but our object hierarchy is too complicated to serialize every class that’s an attribute of another.

To get it to work, i had to change the webconfig:

<sessionState mode="SqlServer" timeout="10" allowCustomSqlDatabase="true" partitionResolverType="Microsoft.Office.Server.Administration.SqlSessionStateResolver, Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

to

<sessionState mode="InProc" timeout="10" />

Apparently, you can’t use SqlServer mode for the session state, which is the default for sharepoint.

Adjusting the width of strings in C#

February 7, 2008

For testing purposes, i’m printing some objects and their values to the console. I want to have nice columns which can be used to compare values and make sure the information is correct.

I search the Internet for about 10-15 minutes, and look at a lot of examples of string formatting, but nothing i found says “this will format the string to be exactly X number of characters”. Since i was just wasting time looking to no avail, i decided to write a method to do that. It’s not the most efficient thing, but it gets the job done.

Since this is only for testing purposes, this is OK. But there’s got to be something somewhere in the .NET framework to do this. Right?


private string AdjustLength(string stringToAdjust, int length)
{
    if (stringToAdjust.Length == length)
    {
        return stringToAdjust;
    }
    else if (stringToAdjust.Length > length)
    {
        return stringToAdjust.Substring(0, length);
    }
    else
    {
        int charsToAdd = length - stringToAdjust.Length;
        string result = stringToAdjust;
        for (int i = 0; i < charsToAdd; i++)
        {
            result += ' ';
        }
        return result;
    }
}


Follow

Get every new post delivered to your Inbox.