Creating an ASPState Database

Create an ASPState database .
 
To generate an ASPState database you need to use the ASPNET_REGSQL command line application within the relevant Framework directory under the Microsoft.NET directory. I am using Windows Server 2008 R2 (64-Bit) so it is located in the C:WindowsMicrosoft.NETFramework64v2.0.50727 directory. A quick tip when using VistaWindows7Windows2008 if you hold down the Shift key and right-click in a blank space in Windows Explorer you get the option to ‘Open Command Window here’ just to save a bit of time and typing.
 
An example of a simple installation of the ASPState database would be; aspnet_regsql – ssadd -sstype t -S <servername> -U <username> -P <password>
For more details on the full list of command line options take a look at http://msdn.microsoft.com/en-us/library/x28wfk74.aspx
 
 

Identifying SQL Server version information

How to identify SQL Server version information.
 
It couldn’t be much easier, really. Run the following T-SQL Script SELECT SERVERPROPERTY(‘productversion’), SERVERPROPERTY (‘productlevel’), SERVERPROPERTY (‘edition’) 
 
For more information on the results it returns have a look at the following KB article ; http://support.microsoft.com/kb/321185

Converting Byte Arrays to Strings (C#)

It’s a lot easier than you think!
 
This is as much as a reminder to myslef as a helpful hint for other people. If you need to convert a byte array to a string the you can use the System.BitConverter class and the ToString() method which accepts a byte array as a parameter. For more information have a look at http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx 
 
I used this for debugging SQL Server Timestamp columns so that I could get a more readable version of the column contents.

IIS Hosted Service Fails

The remote server returned an unexpected response: (405) Method not allowed.
 
A colleague of mine was setting up a web service on a new machine but when he tried to test the reponse from the service he got this error. The solution to the problem as he found was provided here : http://msdn.microsoft.com/en-us/library/ms752252.aspx

‘Double Hop’ issue from Remote Report Server using the ReportViewer control

HTTP 401.1 – Unauthorized: Logon Failed.
 
Whilst helping to develop an intranet application that used the SQL Server 2008 Reporting Services ReportViewer we came across the problem of authenticating users across servers. 
 

The Problem :

 

An intranet application requires support for authentication using a Windows Identity and this identity needs to be used to control access to reports . In a  scenario where the Web Server hosting the application resides on a different machine to the Report Server the authentication process is required to do a ‘Double Hop’ (Web Client -> Web Server -> Report Server) in order to access the remote resources (the reports) on the Report Server.

 

The ‘Double Hop’ issue to access these remote resources means that delegation is required.

 

Standard impersonate-level impersonation tokens that are usually created when you enable impersonation allow you to access local resources only. To be able to access remote network resources, you require a delegate-level token. To generate a delegate-level token when you impersonate, you need to use Kerberos authentication and your process account needs to be marked as trusted for delegation in Active Directory.

 

(Taken from http://msdn.microsoft.com/en-us/library/ms998358.aspx#paght000025_configuringwindowsauthentication)

 

The Investigation :

 

Having set up the necessary servers to simulate the client environment I researched numerous other solutions to the problem as this is  a common issue encountered by other web developers using the ReportViewer control from the web site to access a remote report server. All the research pointed to the issue of delegation and ensuring that the machines are trusted for delegation.

 

If you access this Web site from a browser while logged onto a different machine in the same domain and the Web site attempts to access network resources, you end up with a null session on the remote server and the resource access will fail. To access remote resources, you need delegation.

 

(Taken from the same article listed above)

 

Since delegate-level tokens when impersonating requires Kerberos authentication I came to the conclusion that the missing link in our server configuration was the ‘Trust for delegation’ setting. Having got the IT department to make the relevant changes to the servers in the AD and rebooted the machines our web application was able to display reports from within the application.

 

The Solution :

 

The solution comes in two parts;

     Internet Explorer security settings must be configured to enable Integrated Windows authentication. By default, Integrated Windows authentication is not enabled in Internet Explorer 6 (or above). To enable the browser to respond to a negotiate challenge and perform Kerberos authentication, select the Enable Integrated Windows Authentication check box in the Security section of the Advanced tab of the Internet Options menu, and then restart the browser. It is also advisable to make sure the server running the web application is added to the list of Intranet Sites in the security settings for the browser and that ‘Automatic Logon only in Intranet Zone’ is also set.

     If this server running IIS is a member of the domain but is not a domain controller, the computer must be trusted for delegation for Kerberos to work correctly. This information is taken from the following article – http://support.microsoft.com/kb/907272 .

 

Supporting Documents:

 

For information on what changes are required to the AD please see the following article – http://technet.microsoft.com/en-us/library/cc738491(WS.10).aspx

 

Find method using WhereClause and DateTime values

The netTiers Find method using a WhereClause only accepts ‘=’ values.
 
I have posted my findings about this issue here – http://community.codesmithtools.com/forums/t/9948.aspx
 

Windows 7 RC1 and wireless networking

Enjoying being a Windows user again.
 
I have had Windows 7 RC1 installed on a partion of my desktop machine at home for a few weeks and have been reaping the benefits of the new OS. Having recently purchased a new laptop for more general use around the house I decided to take the plunge and see how it performed on this newer piece of hardware. The laptop was a standard Dell Inspiron 1525 purchased from retail outlet that came pre-installed with Vista Home Premium edition and all the usual Dell extra’s. The Windows 7 installation went very smoothly and all the pieces of hardware were recognised and the drivers installed.
 
My only problem occurred when I tried to connect the laptop to my wireless network running WPA-PSK encryption. Windows 7 would recognise the existence of the wireless network but it would not allow accept the personal security key that I was using. Obviously, I was not the only person experiencing this issue with the wireless network within Windows 7. The solution was relatively painless. I just need to update the driver for the wireless hardware to the current one offered by Dell for Vista.
 
Having downloaded and installed the Vista 32-bit wireless card driver for my 32-bit Windows 7 OS and then done a quick reboot I was able to connect the laptop to my wireless network.
 
 

Accessing other resource files in your web application

Using GetLocalResourceObject() to access resource files from other resource objects.
 
I have been doing some work on localising (localizing…no pun intended) a website. One of the issues I have found is that there may be an occassion that I would want to access the resource key from other local resource objects. For example, I can use GetLocalResourceObject("resourceKey1.Text") to get a text value for the current ASPX page that I am working on. I can also use the HttpContext class to access the same resource keys by specifiying HttpContext.GetLocalResourceObject(Page.AppRelativeVirtualPath, "resourceKey1.Text");
 
So, this got me thinking. Can I do the same think to access resource keys for another page using the same method? The answer is, Yes. I just need to replace the Page.AppRelativeVirtualPath with a virtual path to the page I am interested in and look for the relevant resource key in the resource file. For example, HttpContext.GetLocalResourceObject("~/MyFolder/MyPage.aspx", "resourceKey2.Text" ); will find the entry for resourceKey2.Text in the resource file MyPage.aspx.resx in the App_LocalResources folder.

System.MissingMethodException

Method not found: ‘System.Web.UI.IDataSource System.Web.UI.WebControls.DataBoundControl.get_DataSourceObject()’.
 
I got the error above when calling the IPostBackEventHandler.RaisePostBackEvent on a web page running on a server used for testing. Since it wasn’t occuring on any of the development machines then simple logic meant there had to be a difference in the assemblies residing on the server. In this case it was the version of the .Net Framework 3.5 as the server had not had SP 1 installed. Once the machine had been updated the problem was resolved.

Default Resource Files in Assemblies

How do I access string resources in the default resource file for an assembly? 
 
Accessing strings in a resource file for a web application is fairly straight forward using GetLocalResourceObject and GetGlobalResourceObject. Since the web application that I am currently writing uses additional assemblies I needed a way to localise some of the string values stored in these files. Obviously, I can add individual resource files to this separate assembly and access then using the ResourceManager. One of the articles I read about this included this one http://www.codeproject.com/KB/cs/cs-multi-assembly-res.aspx.
 
My issue was that I didn’t know how to access the content when adding a default resource file. The default resource file is generated when you view the Properties of an assembly and select the Resources tab. If you have not already created a default resource fle you will see the message This project does not contain a default resource file. Click here to create one.  Once you have selected this option and created the default file, the question is how to I get to the content stored in it?
 
The answer is from the resource manager but ensuring you specify the full baseName parameter for the ResourceManager constructor. For example, if I have an assembly with an Assembly Name of MyAssembly.SomeNamespace and have created a default resource file called Resources.resx then I can access a string resource in the default resource file using the following code;
 

ResourceManager rm = new ResourceManager("MyAssembly.SomeNamespce.Properties.Resources", Assembly.GetExecutingAssembly());

string

myString = rm.GetString("MyStringResource");

This is because the default resource file resides under the Properties folder of the satellite assembly. Details about the resource manager can be found here http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.aspx