Monday, July 1, 2013

SharePoint 2010 REST error - Internet Explorer does not support this feed format

I was trying to access List items over REST from the browser and kept getting an IE error-

Internet Explorer does not support this feed format

To resolve this I went into Internet Options under settings in the browser toolbar -->Content --> Feed and Web sites --> Settings and unchecked the Turn on feed reading view. And the solution worked like a charm.


Friday, July 13, 2012

SharePoint 2010 : Naming conventions for files,folders and sites

Sharing some basic information that may take a while to find on the web-

SharePoint 2010 guidelines for Site names, subsite names, or site group names


You cannot use the following characters anywhere in a site name, in a subsite name, or in a site or Active Directory group name:
  • tilde (~)
  • number sign (#)
  • percent (%)
  • ampersand (&)
  • asterisk (*)
  • braces ({ })
  • backslash (\)
  • colon (:)
  • angle brackets (<,>)
  • question mark (?)
  • slash (/)
  • plus sign (+)
  • pipe (||)
  • quotation mark (")
You cannot start a site name, subsite name, or a site group name with an underscore (_) character or with the period character.


You cannot use the period character consecutively in the middle of a site name, a subsite name, or a site group name.


•You cannot use the period character at the end of a site name, a subsite name, or a site group name.

Folder names

You cannot use the following characters anywhere in a folder name or a server name:
  • tilde (~)
  • number sign (#)
  • percent (%)
  • ampersand ("&")
  • asterisk (*) 
  • braces ({ })
  • backslash (\)
  • colon (:)
  • angle brackets "<",">")
  • question mark (?)
  • slash (/)
  • plus sign (+)
  • pipe ("||") 
  • quotation mark (")
 
 
You cannot use the period character consecutively in the middle of a folder name.

•You cannot use the period character at the end of a folder name.

•You cannot start a folder name with the period character.


File names

You cannot use the following characters anywhere in a file name:

  • tilde (~)
  • number sign (#)
  • percent (%)
  • ampersand ("&")
  • asterisk (*)
  • braces ({ })
  • backslash (\)
  • colon (:)
  • angle brackets "<",">")
  • question mark (?)
  • slash (/)
  • plus sign (+)
  • pipe ("||")
  • quotation mark (")

•You cannot use the period character consecutively in the middle of a file name.
•You cannot use the period character at the end of a file name.
•You cannot start a file name with the period character.

In addition, file names and folder names may not end with:

  • .files
  • _files
  • -Dateien
  • _fichiers
  • _bestanden
  • _file
  • _archivos
  • -filer
  • _tiedostot
  • _pliki
  • _soubory
  • _elemei
  • _ficheiros
  • _arquivos
  • _dosyalar
  • _datoteke
  • _fitxers
  • _failid
  • _fails
  • _bylos
  • _fajlovi
  • _fitxategiak
Courtesy :
http://support.microsoft.com/kb/905231

Thursday, March 22, 2012

VisualWebPart error +--- is not allowed here because it does not extend class 'System.Web.UI.UserControl'."}

{"'TestWebPart.Test.TestUserControl' is not allowed here because it does not extend class 'System.Web.UI.UserControl'."}

I got this error when I copy pasted some code from another file and pasted on to an existing web part file.

The reason was that the namespaces were out of sync. Once I fixed that it worked fine ;)

Silly mistake but could take some time to realise
Cheers!

Wednesday, March 7, 2012

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map

.Net Error
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map

I got this error when I was trying to open a .aspx page on my Windows 7 machine. I realized I had installed IIS after .Net Framework. Hence, I had to re register my .NET framework on to IIS.

This is what I did to get rid of the error-
  • I have a 32 bit server so I navigated to the folder where my .Net framework files reside which in my case is -
             C:\Windows\Microsoft.NET\Framework\v4.0.30319

            and copied the path.
  • I opened the command prompt (run cmd from the Start menu)
  • did a cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
         to change directory
  • Ran the command aspnet_regiis -i
which Installs the version of ASP.NET that is associated with Aspnet_regiis.exe and updates the script maps at the IIS metabase root and below.

Only the script maps for applications that use an earlier version of ASP.NET are updated. Applications that use a later version are not affected.
Refer http://msdn.microsoft.com/en-us/library/k6h9cz8h%28VS.80%29.aspx for details
  • And then browsed my page again and voila it worked!
The logic is to use the ASP.NET IIS Registration Tool to register the .NET framework again

If aspnet_regiis -i doesn't do the job also try aspnet_regiis -ir

Merci!!

Tuesday, February 28, 2012

SharePoint 2010 : Get rid of %20 in List Names

Often in my projects I hit the 250 character limit in the URL because of a number of %20 which is the  URL encoding for a space.

One way is to convince my practioners that using an "_" or Camel Casing is the way to go. 

The other common trick that I employ is to Create my List, View, Library with no spaces so then my URL has no %20 and then go and rename the List,View, Library etc. Since the URL doesn't change on renaming I got my URL with lesser characters and my name the way the Business wants it .

Bingo!!

Sunday, February 12, 2012

SharePoint 2010 - Save Site as Template error

I was trying to save my site as Template from the Site Settings page and got an unauthorized exception with a co relation id.
I went to the SharePoint  logs
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS
and found the following error on click of save site as template-
w3wp.exe (0x1A14)                           0x0998    SharePoint Foundation             General                           9fjl    Monitorable    SPSolutionExporter: System.UnauthorizedAccessException: Access to the path 'C:\Temp\SPSolutionExporter-5745c17f-255e-465e-81c9-aecb1fbce9b9\Test1ListInstances\Files\FormServerTemplates\Schema.xml' is denied.     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 buffe...    9987739f-cb79-459e-b92a-24342b6591aa


I found a solution on technet and granted the app pool account my web app was running under access to C:\Temp folder. And it worked like a charm!

Cheero!


Wednesday, January 19, 2011

Convert DBASE DBF files to html,txt

This is a nice tool to convert .DBF files which are from DBASE to html or txt
http://www.dbfview.com/dbf-to-xls.html

The trial version helps you convert to html or txt. The licensed one converts to other formats like excel,sql and csv. A nice find!

Thursday, August 12, 2010

SharePoint 2007 CSS Bible

Click here for Heather Solomon's Sharepoint 2007 CSS bible
http://www.heathersolomon.com/content/sp07cssreference.htm

Wednesday, August 11, 2010

Get the GUID of a SharePoint List

I usually adopt this easy way of finding the GUID of a SharePoint List:
Go to the List or Library settings --> then right-click on the “Audience targeting settings” or “Information management policy settings” links and choose Copy Shortcut.

Paste this Copied Shortcut in a notepad.
You get a URL like this:

http://stdemo:36068/eaTest/_layouts/ListEnableTargeting.aspx?List={d50cb13c-4cf2-4569-9e5c-b9363c39bdb9}
The one in bold red between the braces is your List GUID

Updating a SharePoint List Item with a LookUp Column

I got this error
"Invalid data has been used to update the list item. The field you are trying to update may be read only" when I was trying to Update a List with a LookUp column called "Group".
This column looked up values from another list. The solution was to update the ID of the lookup column and it worked .
Here is the code snippet for the above:
SPList lst = listWeb.Lists[listName];
//Get the items of the list
SPListItem item = lst.Items.GetItemById(ItemID);

//Set the item of the list to the corresponding Group Name from the "LookUp" list .Note Group1 is the Internal name of the column Group
item["Group1"] = intGroupID;
listWeb.AllowUnsafeUpdates = true;
//The argument false for SystemUpdate informs the SPObject Model not to increment versions
item.SystemUpdate(false);
listWeb.AllowUnsafeUpdates = false;

Monday, August 2, 2010

Add Ajax 3.5 support in SharePoint

Here is an excellent link to add Ajax 3.5 support in SharePoint 2007. The author has detailedd the changes to the web.config

http://www.zimmergren.net/archive/2008/09/22/how-to-get-up-and-running-with-net-3-5-in-your-sharepoint-environment.aspx

Thursday, June 17, 2010

C# ,Impersonation for Cross Domain access

C# , Impersonation to write to a file outside the domain in a shared network location
I had a scene wherein I had to write to a file in a network location outside the domain using a domain Id.
The regular values for LogonUser() didn't work for me. So I changed the values for Cross Domain access.

This is the snippet that was different:
enum LogonType
{
Interactive = 2,
Network = 3,
Batch = 4,
Service = 5,
Unlock = 7,
NetworkClearText = 8,
NewCredentials = 9
}
enum LogonProvider
{
Default = 0,
WinNT35 = 1,
WinNT40 = 2,
WinNT50 = 3
}
LogonUser(
userName,
domain,
password,
(int)LogonType.NewCredentials,
(int)LogonProvider.WinNT50,

//LOGON32_LOGON_INTERACTIVE,
//LOGON32_PROVIDER_DEFAULT,
ref token) != 0)


Here is my complete code:
namespace Tools
{
#region Using directives.
// ----------------------------------------------------------------------

using System;
using System.Security.Principal;
using System.Runtime.InteropServices;
using System.ComponentModel;

// ----------------------------------------------------------------------
#endregion

/////////////////////////////////////////////////////////////////////////

///
/// Impersonation of a user. Allows to execute code under another
/// user context.
/// Please note that the account that instantiates the Impersonator class
/// needs to have the 'Act as part of operating system' privilege set.
///

///
/// This class is based on the information in the Microsoft knowledge base
/// article http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158
///
/// Encapsulate an instance into a using-directive like e.g.:
///
/// ...
/// using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) )
/// {
/// ...
/// [code that executes under the new context]
/// ...
/// }
/// ...
///
///
///

public class Impersonator :
IDisposable
{
#region Public methods.
// ------------------------------------------------------------------

///
/// Constructor. Starts the impersonation with the given credentials.
/// Please note that the account that instantiates the Impersonator class
/// needs to have the 'Act as part of operating system' privilege set.
///

/// The name of the user to act as.
/// The domain name of the user to act as.
/// The password of the user to act as.
public Impersonator(
string userName,
string domainName,
string password)
{
ImpersonateValidUser(userName, domainName, password);
}

// ------------------------------------------------------------------
#endregion

#region IDisposable member.
// ------------------------------------------------------------------

public void Dispose()
{
UndoImpersonation();
}

// ------------------------------------------------------------------
#endregion

#region P/Invoke.
// ------------------------------------------------------------------

[DllImport("advapi32.dll", SetLastError = true)]
private static extern int LogonUser(
string lpszUserName,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
ref IntPtr phToken);

[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern int DuplicateToken(
IntPtr hToken,
int impersonationLevel,
ref IntPtr hNewToken);

[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool RevertToSelf();

[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern bool CloseHandle(
IntPtr handle);

private const int LOGON32_LOGON_INTERACTIVE = 2;
private const int LOGON32_PROVIDER_DEFAULT = 0;
enum LogonType
{
Interactive = 2,
Network = 3,
Batch = 4,
Service = 5,
Unlock = 7,
NetworkClearText = 8,
NewCredentials = 9
}
enum LogonProvider
{
Default = 0,
WinNT35 = 1,
WinNT40 = 2,
WinNT50 = 3
}

// ------------------------------------------------------------------
#endregion

#region Private member.
// ------------------------------------------------------------------

///
/// Does the actual impersonation.
///

/// The name of the user to act as.
/// The domain name of the user to act as.
/// The password of the user to act as.
private void ImpersonateValidUser(
string userName,
string domain,
string password)
{


WindowsIdentity tempWindowsIdentity = null;
IntPtr token = IntPtr.Zero;
IntPtr tokenDuplicate = IntPtr.Zero;

try
{
if (RevertToSelf())
{
if (LogonUser(
userName,
domain,
password,
(int)LogonType.NewCredentials,
(int)LogonProvider.WinNT50,

//LOGON32_LOGON_INTERACTIVE,
//LOGON32_PROVIDER_DEFAULT,
ref token) != 0)
{
if (DuplicateToken(token, 2, ref tokenDuplicate) != 0)
{
tempWindowsIdentity = new WindowsIdentity(tokenDuplicate);
impersonationContext = tempWindowsIdentity.Impersonate();
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
finally
{
if (token != IntPtr.Zero)
{
CloseHandle(token);
}
if (tokenDuplicate != IntPtr.Zero)
{
CloseHandle(tokenDuplicate);
}
}
}

///
/// Reverts the impersonation.
///

private void UndoImpersonation()
{
if (impersonationContext != null)
{ impersonationContext.Undo(); }
}

private WindowsImpersonationContext impersonationContext = null;

// ------------------------------------------------------------------
#endregion
}

/////////////////////////////////////////////////////////////////////////
}


For more details refer to :
http://www.cstruter.com/blog/270 which helped me .

Cheers!

Wednesday, June 16, 2010

Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf385

Ajax Error :
Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf385

I got this error while trying to use the Calendar control extender from the Ajax Control Toolkit for one of my textboxes.
First I got an error "sys.extended.ui is null or not an object" . To fix this, I changed the ScriptManager control to use the "ToolkitScriptManager" .
Once I did that I started getting this new error:Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf385
This got resolved once I installled .Net Framework 3.5 SP1.
That got my Ajax calendar control working like a charm ;)

Thursday, May 27, 2010

How to stop the !New icon from appearing in SharePoint Lists

I had this weird requirement from my client to remove the !New icon when a new document or item is added to a list.I followed these steps also outlined in the Microsoft support blog:

To stop the !New tag from appearing for new entries on your Windows SharePoint Services Web site, follow these steps, as appropriate for your version of SharePoint Services.
-Windows SharePoint Services 3.0 Web site
To stop the !New tag from appearing next to new entries on a Windows SharePoint Services 3.0 Web site, use the Stsadm.exe tool to change the "Days to Show New Icon" property to zero.

To do this, follow these steps:
1)Click Start, point to All Programs, point to Accessories, and then click Command Prompt.
2)Type the following commands, and then press ENTER after each command:
cd /d %programfiles%\Common Files\Microsoft Shared\Web Server Extensions\12\BIN
stsadm.exe -o setproperty -pn days-to-show-new-icon -pv 0 -url [Your Virtual Server's URL]

-Windows SharePoint Services Web site
To stop the !New tag from appearing next to new entries on a Windows SharePoint Services Web site, use the Stsadm.exe tool to change the "Days to Show New Icon" property to zero.

-To do this, follow these steps:
Click Start, point to All Programs, point to Accessories, and then click Command Prompt.
Type the following commands, and then press ENTER after each command:
cd /d %programfiles%\Common Files\Microsoft Shared\Web Server Extensions\60\BIN
stsadm.exe -o setproperty -pn days-to-show-new-icon -pv 0 -url [Your Virtual Server's URL]

-SharePoint Team Services Web site
To stop the !New tag from appearing next to new entries on a SharePoint Team Services Web site, use the Owsadm.exe tool to change the "New Item Display Cutoff" property to zero.

To do this, follow these steps:
Click Start, point to All Programs, point to Accessories, and then click Command Prompt.
Type the following commands, and then press ENTER after each command:
cd /d %programfiles%\Common Files\Microsoft Shared\Web Server Extensions\50\BIN
owsadm.exe -o setproperty -pn NewItemDisplayCutoff -pv 0 -p [Your Virtual Server's Port]

Tuesday, May 4, 2010

Setting up User Accounts in SharePoint 2007 :Useful Tips to share

  • A few years back,I was not sure of how User Accounts in SharePoint 2007 should be set up.
    Here is an useful extract I found to guide me:
    If you are installing SharePoint properly, you'll use the 'least privilege account principle'; this basically means that each distinct service inside the SharePoint farm will have its own domain user account. These accounts should have the minimum privileges that they need to perform their jobs. There is a great document which goes into detail on each different account (8+ accounts) here, however in summary, you should have the following accounts:
  • SQL Server Service Account: Account used by SQL to run all SQL services
  • Server Farm Account
  • SSP Service Account
  • Office SharePoint Server Search Account
  • Default Content Access Account
  • User Profile and Properties Content Access Account
  • Excel Services Unattended Account
  • One account per application pool: This is typically three accounts; SSPAdministration, MySite and your main 'Portal' or 'Intranet'.

For more information refer to this
http://technet.microsoft.com/en-us/library/cc263445.aspx

Tuesday, April 20, 2010

Infopath 2007 : Button Click event fired only once



I was trying to have multiple Rules on a Button on an InfoPath 2007 form. But I saw that only the rule on the first click is fired. All other rules don't get executed.

This is what I did to resolve the issue: Make that the checkbox that says "Stop Processing rules when this rule finishes " is checked for all the Rules to fire on Button click.

Make sure that on the Button properties --> Browser Forms you have the option of "Always" selected to send data to server on button click


This should make your button Rules fire on every click ! Happy Clicking!!

Infopath 2007 : Only first row of repeating table is committed to the database

This was a weird issue I came up with. Here is the background :

I was using Infopath 2007 to receive and submit data to a web service.

I had a repeating table bound to the receiving data and it displayed all the rows. But while submitting only the first row of the repeating table got committed.

Here is what I did to resolve the issue:

I had only one level in the receiving data schema a group called called TestData1 . Because of this the webservice was getting to the child level but not to the parent level. I added one more level in the webservice to change the schema to have TestData1 and then TestData1 again below it .

The web service was modified by adding a new class for the array which included one more level as below:


[WebMethod]

public TestDataArray getTestDataFilteredSorted(string USERNAME, string SORTCOLUMN, string SORTDIRECTION, string QUERY_NUM, string STUDY, string SITE, string QUERY_ID, string SUBJECT, string REVIEW_STATUS)
{
TestData filterTestData = new TestData();
filterTestData.QUERY_NUM = QUERY_NUM;

filterTestData.STUDY = STUDY;
filterTestData.SITE = SITE;
filterTestData.QUERY_ID = QUERY_ID;
filterTestData.SUBJECT = SUBJECT;
filterTestData.REVIEW_STATUS = REVIEW_STATUS;
TestDataArray filterTestDataArrayobj = new TestDataArray();
filterTestDataArrayobj.TestData1 = getTestDataFiltered2(USERNAME, filterTestData, SORTCOLUMN, SORTDIRECTION);

return filterTestDataArrayobj;
}
public class TestDataArray
{
public TestData[] TestData1;
}
Also note that while configuring the submit data connection make sure that you select the top group of TestData under field or group and Select "XML subtree" under include.
With all this configured you should be able to commit more than one row of the repeating table

Tuesday, March 16, 2010

SharePoint + InfoPath : An error occurred accessing data source

InfoPath forms and SharePoint are a deadly combination. Only with long association with these two does one understand how both need to be configured to work in harmony !

Here is an example of an error one gets many times while working with these two and webservices. I got "an error occurred while accessing a data source" while accessing my InfoPath forms on SharePoint 2007 site from any machine on the domain other than my SharePoint server where I had deployed my forms.

My forms were accessing a web service deployed onto the server and I was trying to access my SharePoint site from any other machine on the domain.

How I resolved it
Set the Security and Trust to "Domain" . It was set to "automatically determine security level".
you can do this by going to :
Tools -->Form Options -->Security and Trust

Cheers :)!