Welcome to MSDN Blogs Sign in | Join | Help

This is a great article on how to implement table inheritance in SQL Server.

http://technet.microsoft.com/en-us/office/sharepointserver/cc948709.aspx

 

After migrating an ASP.NET 1.1 website to 2.0, I wanted to find out how much faster the new website runs.  So I used VSTS (Test Edition) to record a few web tests with the intention of running those tests against the new and old websites to measure whether there were any performance gains.  The web tests were recorded against the new website (ASP.NET 2.0).  When I replay the tests against the old site, I got the following error:

 Request failed: Context parameter '$HIDDEN1.__EVENTVALIDATION' not found in test context

After an hour of digging around, I found that you have to make the following modifications to the web tests in order to replay it against an ASP.NET 1.1 website:

-       Make a copy of the web test

-       Open the web test in notepad (web test is an XML file)

-       Remove all FormPostParameter elements with the name “__EVENTVALIDATION”

-       Replace all instances of “ctlXX$” with “_ctlX:”, i.e., replace ctl00$ with _ctl0:

 

 

 

All this time, I've mistakenly thought that System.Web.Caching.Cache can only be used in web applications.  It turns out that is not true.  You can use the web cache in Console or WinForm applications.  Here's some sample code showing how that's done. 

Note: Documentation for the Cache class explitcitly states that it was designed and tested for use in ASP.NET.  Although I've shown that it can be used in console and WinForm applications, using the Cache class outside of ASP.NET is not supported by Microsoft. 

Using Web Cache in a Console Application:

Module Module1

 

    Private Const CACHE_KEY As String = "testcache"

    Private Const CACHE_DURATION_SECONDS As Double = 10

 

    Sub Main()

 

        Do

            PrintInstructions()

 

            Dim ki As ConsoleKeyInfo = Console.ReadKey(True)

            Dim command As String = ki.Key.ToString().ToLower()

 

            Select Case command

                Case "q"

                    Exit Sub

 

                Case "i"

                    Console.WriteLine("Please enter value you would like to insert into the cache")

                    Dim cacheValue As String = Console.ReadLine()

                    Dim cacheExpiration As DateTime = DateTime.Now.AddSeconds(CACHE_DURATION_SECONDS)

                    System.Web.HttpRuntime.Cache.Insert(CACHE_KEY, cacheValue, _

                                                Nothing, _

                                                cacheExpiration, _

                                                System.Web.Caching.Cache.NoSlidingExpiration)

                    Console.WriteLine(cacheValue & " has been inserted into the cache.  It will expire at " & cacheExpiration.ToLongTimeString())

 

                Case "r"

 

                    Dim cacheValue As Object = System.Web.HttpRuntime.Cache.Get(CACHE_KEY)

 

                    If (cacheValue Is Nothing) Then

                        Console.WriteLine("Nothing in the cache")

                    Else

                        Console.WriteLine(cacheValue.ToString() & " - current time: " & Now.ToLongTimeString())

                    End If

 

                Case Else

                    PrintInstructions()

            End Select

        Loop While True

 

    End Sub

 

    Sub PrintInstructions()

        Console.WriteLine("===========================================")

        Console.WriteLine("Please enter any of the following commands:")

        Console.WriteLine("    i - insert a value into the cache")

        Console.WriteLine("    r - display whatever is in the cache")

        Console.WriteLine("    q - quit")

        Console.WriteLine("===========================================")

    End Sub

End Module

 

Using Web Cache in a WinForm Application:

Public Class Form1

 

    Private Const CACHE_KEY As String = "testcache"

    Private Const CACHE_DURATION_SECONDS As Double = 10

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim cacheValue As Object = System.Web.HttpRuntime.Cache.Get(CACHE_KEY)

 

        If (cacheValue Is Nothing) Then

            MessageBox.Show("Nothing in the cache")

        Else

            MessageBox.Show(cacheValue.ToString() & " - current time: " & Now.ToLongTimeString())

        End If

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim cacheExpiration As DateTime = DateTime.Now.AddSeconds(CACHE_DURATION_SECONDS)

        System.Web.HttpRuntime.Cache.Insert(CACHE_KEY, TextBox1.Text, _

                                    Nothing, _

                                    cacheExpiration, _

                                    System.Web.Caching.Cache.NoSlidingExpiration)

        MessageBox.Show(TextBox1.Text & " has been inserted into the cache.  It will expire at " & cacheExpiration.ToLongTimeString())

    End Sub

End Class

 

 

I spent a couple of hours trying to figure out why I keep getting an exception with an error code of 0x80040E14 whenever I try to programmatically update a list item.  Found this blog entry which describes exactly what I experienced.  A quick fix for this problem is to either turn versioning off for the list or use SPListItem.SystemUpdate.

Follow these simple steps to encrypt sections of your configuration files

 

1.     Create a custom machine-level RSA key container by running aspnet_regiis.exe

 

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pc “MyKeys” -exp

§  The -pc option followed by the name of the RSA key container, to create the RSA key pair.

§  The -exp option, to make sure that the key is exportable.

 

2.        Granting Read Access to an RSA Encryption Key.  The following command assumes your application is running under the NETWORK SERVICE account.

 

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"

§  The -pa option followed by the RSA key container name "MyKeys"

§  The identity of your ASP.NET application, as determined in the preceding step

 

3.        Specify a protected data provider that uses the custom key container just created.  Add the following <configProtectedData> section to your web.config.  Save and close web.config file when done.

 

<configuration>

    <configSections>

      

   </configSections>

 

   <configProtectedData>

      <providers>

         <add name="MyProvider"

              type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration,

                          Version=2.0.0.0, Culture=neutral,

                          PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"

              keyContainerName="MyKeys"

              useMachineContainer="true" />

      </providers>

   </configProtectedData>

  

</configuration>

 

4.        Provide setting values for the configuration section which you want to encrypt.  You can provide settings to standard config sections like connnectionStrings or your own custom section.  Following is an example of a custom config section with unencrypted setting values.

 

<configuration>

    <configSections>

       <section name="SensitiveAccountInfo" type="System.Configuration.SingleTagSectionHandler" />

      

   </configSections>

   <configProtectedData>

      

   </configProtectedData>

 

   <SensitiveAccountInfo domain="tvland" userName="gary" password="watchatalkinboutwillis?" />

</configuration>

 

5.        Encrypt sections of the web.config file

 

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "SensitiveAccountInfo" "path"   -prov “MyProvider”

§  The –pef option:

ú  Followed by “SensitiveAccountInfo", to specify which section in web.config file to encrypt. 

ú  Followed by “path” which is the path to the folder containing the web.config file

§  The –prov option, followed by “MyProvider”, to specify which provider to user to encrypt the data

 

6.        Access decrypted configuration settings by using the following code.

 

Hashtable acctInfo = (Hashtable) ConfigurationManager.GetSection("SensitiveAccountInfo ");

string domain = (string)acctInfo["domain"];

string userName = (string)acctInfo["userName"];

string password = (string)acctInfo["password"];

 

Follow these steps to deploy key container and web.config to another server

 

So your configuration settings are now encrypted and your web application can decrypt the settings.  What if you want to deploy the config file to a different server or environment?  Follow these steps to export the RSA key container from the current machine and then import it to the next server. 

 

1.        Export a custom RSA key container to an XML file

 

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -px "MyKeys" "c:\keys.xml" -pri

§  The -px option:

ú  Followed by "MyKeys", which is the name of the key container that you created earlier

ú  Followed by the path of an .xml file to export the key container to.

§  The -pri option made sure that private key information is exported.  Otherwise, the exported key information will only encrypt information, not decrypt it.

 

2.        Copy the encrypted web.config file and key container XML file to the new server.  The next step assumes you’ve copied the keys.xml file to C:\.

 

3.        Import a custom RSA key container from an XML file

 

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pi "MyKeys" "c:\keys.xml"

§  The -pi option, followed by "MyKeys", which is the name of the exported key container, to import the RSA key container.

§  The path of the .xml file that contains the exported key container

 

4.     Delete the keys.xml file.  You’re done with it.

 

5.        Granting Read Access to an RSA Encryption Key.  The following command assumes your application is running under the NETWORK SERVICE account.

 

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pa "MyKeys" "NT AUTHORITY\NETWORK SERVICE"

§  The -pa option followed by the RSA key container name "MyKeys"

§  The identity of your ASP.NET application, as determined in the preceding step

 

Refer to this MSDN article for more details about the above instructions.

I was given a temporary development laptop with Vista installed.  There are the usual development tools and SQL Server Developer Edition.  When I tried logging onto the local SQL Server instance, I got accessed denied.  I'm part of the local Administrators group, so I should be able to log on as SA.  I couldn't figure out why this was until someone else told me to "Run as administrator".  I totally forgot about the Vista UAC.  As a developer, the first thing I do to my laptop was to turn UAC off.  I forgot to do it for this laptop, so that's why I got access denied. 

Anywas, if anyone encounter this problem, then you can run SQL Server Management Studio as administrator by right-clicking on the menu item and choose "Run as administrator".  Or you can turn off UAC by going to "Control Panel", "User Accounts", "turn User Account control on or off", and uncheck the checkbox.

 

Ever got the following parser error on one of your page layouts? 

 Only Content controls are allowed directly in a content page that contains Content controls.

Following the error message, it shows the source containing some HTML fragment that you never added yourself.  I got this error when I used all lower case for the content tag, as in <asp:content>.  This error goes away when I change the casing of the tag to <asp:Content>.

If your “content access” account doesn’t have permission to manage user profiles, then you may see event 7888 in your Application Event Log like this:

 

Description:

A runtime exception was detected. Details follow.

Message: Access Denied! Only site admin can access Data Source object from user profile DB.

 

Technical Details:

System.UnauthorizedAccessException: Access Denied! Only site admin can access Data Source object from user profile DB.

   at Microsoft.Office.Server.UserProfiles.SRPSite.AdminCheck(String message)

   at Microsoft.Office.Server.UserProfiles.DataSource._LoadDataSourceDef(IDataRecord rec)

   at Microsoft.Office.Server.UserProfiles.DataSource._LoadDataSourceDef(String strDSName)

   at Microsoft.Office.Server.UserProfiles.DataSource..ctor(SRPSite site, Boolean fAllowEveryoneRead)

   at Microsoft.Office.Server.UserProfiles.DataSource..ctor(SRPSite site)

   at Microsoft.Office.Server.UserProfiles.UserProfileConfigManager.GetDataSource()

   at Microsoft.Office.Server.UserProfiles.BDCConnector.RefreshConfiguration(String sspName)

 

To fix this problem, go to your Shared Services Administration page, click on Personalization services permissions.  Click on  Add Users/Groups.  Type the “content access” account and give it Manage * permissions.

Have you seen an error with event ID 6875 in your Application Event Log?  It looks like this:

Event Type: Error
Event Source: Windows SharePoint Services 3
Event Category: General
Event ID: 6875
Description:
Error loading and running event receiver
Microsoft.SharePoint.Publishing.Internal.ScheduledItemEventReceiver in
Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c. Additional information is below.

Invalid List Item. The List Item provided is not compatible with a Scheduled Item.

If you have, then you can safely ignore it because you will not experience any loss of functionality in SharePoint according to this KB.  This error shows up whenever you publish a page with major version turned on.  You can tell SharePoint not to write this error to the event log by following the instructions in the KB.

 

I have two web sites on a MOSS farm.  The first is reserved for authors and the second one is exposed to the internet allowing anonymous access.  Recently, we receive intermitten 403 errors (Event ID 1314) when a user tries to access a certain page.  This only occurs on the author site.  After some searching, I found references to this error in these threads (objectmix, microsoft)

Basically, there are two workarounds for this problem:

  1. Set <identity impersonate="false" /> in the web.config file.  I actually did this in the public web application, so that's why we never saw this error on the public web site.
  2. Give users access to the web site's bin folder. 

I went with the second workaround.  In addition to the bin folder, I also needed to give users access to the App_Data folder. 

Filemon.exe rocks!  It showed me exactly what I needed to know to fix this problem: the path and user name which is getting the access denied error.

Before moving a content database from one farm to another, remember to prepare the database with the STSADM tool.  Otherwise, you'll get a "Failure trying to synch web application" error.  This blog describes this command in more details.

I'm not sure about other developers, but I hate working with HTML.  Here's an example why…

 I have a few images that need to be arranged in a table to show a page header.  This simply is just some IMG tags inside some other TD tags.  But whenever the header is displayed in IE, there are always extra pixels at the bottom of each TD with an image inside of it.  I tried setting the paddings and margins for the TD's to zeroes, but that didn't work.  If I set the image as the TD background, then the extra pixels goes away.  But I can't use this workaround because there are times when I need to display an image in a TD then set some other image as a background.  It took me days to figure out the cause of this problem:

When I type HTML, I like to add extra white spaces so that it's readable and therefore easier to maintain.  And so the HTML for the above scenario looks like:

<table>

    <tr>

        <td>

            <img src=”some image/>

        </td>

    </tr>

</table>

I thought that browsers will just ignore the extra white spaces, but apparently, that isn’t true.  IE adds extra pixels to the TD whenever you add the extra space after the IMG tag.  In order to fix the problem described above, I had to change the HTML to this:

<table>

    <tr>

        <td><img src=”some image/></td>

    </tr>

</table>

 

 

 

Last week, I spent an all-nighter troubleshooting a Kerberos issue for a MOSS installation.  Although it was very tiring spending an entire day and night fixing this problem, I actually thought it was fun.  I learned a lot about configuring AD for delegation and how to troubleshoot delegation problems.  Before I forget everything I've learned, I'm going to take a few notes here on what helped me so that whenever I'm in the same situation again, I won't have to stay up all night fixing it.

I'm not going to discuss how to setup Kerberos here.  There are plenty of good resources for doing that.  Here are some blogs that really helped me out:

What I'd like to note here are some of the tools I used to debug Kerberos problems.  Some of them were noted in Liam's blog, others I got from internal Microsoft resources:

  • Commands to get/set authentication providers.  The number in the command is the website ID which you can get from IIS Manager

C:\Inetput\AdminScripts\cscript adsutil.vbs get 3svc/1508561879/root/NTAuthenticationProviders

 

C:\Inetput\AdminScripts\cscript adsutil.vbs set 3svc/1508561879/root/NTAuthenticationProviders "Negotiate,NTLM"

 

  • To view authentication schemes for all SQL connections

Select auth_scheme from sys.dm_exec_connections

 

  • In order for Kerberos delegation to work correctly, you need to make sure Service Principal Names for service accounts are configured properly.  You can easily do that by bringing up ADSI Edit and looking at the servicePrincipalName attribute.  But what if you don’t have access to AD?  Try running the DHCheck.vbs script, which is available for download here.  The syntax for this script is:

Cscript chcheck.vbs account1 [account2 [account […]]] where accounts are either service or computer accounts used from end to end.

 

  • Use Microsoft Network Monitor to view Kerberos messages.  Netmon is available from Microsoft Download Center.  It’s best to install netmon on all servers (client, middle tier, and database server) so that you can view Kerberos messages from all perspectives.

 

  • Use Kerbtray to view and purge Kerberos tickets.  Kerbtray is available in the Windows 2000 Resource Kit Tool or it can be downloaded individually from here.

Ever got repeated “Attempted to read or write protected memory” messages on your MOSS servers?  If you do, then the event ID’s are probably 7076, 6398 and 6432.  It seems these errors are related to a bug in the Internet Information Services (IIS) Active Directory Service Interfaces (ADSI) provider.  This blog describes this bug in more details.  You can get the fix here.

More Posts Next page »
 
Page view tracker