Short solution for short problems

Method hiding in c#

It looks kind of strange seeing the new keyword in a method declaration. Here when you should use this:

When you are using a class that is derived and has some simular methods as in the parent class which are not overridden, it will hide these methods.

You get a warning message like this:

Warning 1 'ChildClass.Function()' hides inherited member 'ParentClass.Function()'. Use the new keyword if hiding was intended.

For clarities sake you should use the new keyword in the method declaration of the function that is hiding an other function. So the new keyword is not going to do anything actually, it will remind you that you are hiding an other method. That's why there's a warning and not an error. But do use the new keyword, make it a habbit.

I'm not going to use examples because this site explains it perfectly:


Show WSS docs in ASP.Net site

If you are using a WSS based site on the inside of your company, sometimes you want to share some documents to the outside without sharing the complete library or without giving them acces to your SharePoint site. Then you will need to acces the WSS site with a user and render the document on your ASP.Net page.

This is how I solved it a while ago.

I created a list of documents grom the WSS library on the site using the webservices. Each listitem(ASP.Net list item) provided a link, which had a query string: docurl, that provided the url in the SharePoint document. (If the url is not to be shown, you could use doc ID instead).

Then when you clicked on the link, the url was transmitted via querystring and these functions handled the rendering:

        private byte[] ReadFully(Stream stream)
            byte[] buffer = new byte[32768];
            using (MemoryStream ms = new MemoryStream())
                while (true)
                    int read = stream.Read(buffer, 0, buffer.Length);
                    if (read <= 0)
                        return ms.ToArray();
                    ms.Write(buffer, 0, read);
        private void ShowDocToUser(string s)
            WebClient wc = new WebClient();
            wc.Credentials = GetCredentials();
            Stream data = wc.OpenRead(s);
            byte[] content = ReadFully(data);
            WebHeaderCollection webHeaders = wc.ResponseHeaders;
            Response.ContentType = webHeaders["Content-Type"];

The getcredentials function uses login and password of a user that is configured in the webconfig and has read acces to the library.