2006-12-04

Changing Locale of the ASPNET account

I have a server that has been installed using default language/locale "en-US".

This becomes a problem with the date format, which is "MM/dd/yyyy" in en-US, while in Norway where I live we use (nb-NO) "dd.MM.yyyy".

There is also a problem with which character to use as a decimal point and which to use as a thousand marker/separator:
Norwegian (nb-NO): decimal point is comma (",") , thousand marker is space. Ex: 2 345,67
US English (en-US): decimal point is dot ("."), thousand marker is comma. Ex: 2,345.67

So I need a way to set the locale that the ASPNET account is using.

There are several ways. You can set this in the web.config file:


<system.web>
<globalization
culture="nb-NO"
uiCulture="nb-NO" />
</system.web>


You can also set it in the users session, by using the Session_Start event handler:


protected void Session_Start(object sender, EventArgs e)
{
this.Session.LCID = 1044;
}


If you want to change the default settings of the ASPNET account (and you have the guts), you could go in and change the settings in the registry.

NB! It may be risky to change settings in the registry. The author of this blog is not responsible for any damage that may be caused by doing so.

Anyway here it is, change the settings under the following key:

HKEY_USERS\S-1-5-20\Control Panel\International

Here you can see settings for number formats, date formats languages etc for the user. I have as of now NOT TESTED THIS, but the key for the ASPNET user should according to a news group be S-1-5-20.

Good luck!

2006-09-27

ADODB serialization

Found a simple but cool way to serialize an ADODB Recordset without converting to DataSet on CodeProject.

2006-08-14

Security Developer Center: Security Tips: Defend Your Code with Top Ten Security Tips Every Developer Must Know

Not sure if I have bookmarked this before. Well, better safe than sorry...

2006-06-22

Build your own cryptographically safe server/client protocol - The Code Project - Internet & Network

Good article that explains quite a bit about how cryptography works.

2006-06-15

Some Cool Tips for .NET - The Code Project - C# Controls

Nice to know info on how to get information about windows and other stuff.

2006-05-30

SQL Server Monitoring in 8 Steps: Lessons From the Field

How to get a quick status of the server while on-site.

2006-05-23

Free JavaScript DHTML Website Menus, Cross Browser Popup Web Menu

Nice, free Javascript menus.
The Soul of a Virtual Machine : Sysprepping a virtual machine

Description of how to sysprep a VPC. Useful stuff.

2006-04-04

HttpSecureCookie, A Way to Encrypt Cookies with ASP.NET 2.0 - The Code Project - ASP.NET

This article describes how to encrypt cookies in .NET 2.0.

2006-04-03

The 46 Best-ever Freeware Utilities

This is a nice page with lots of free software links. Among others, web browsers and antivirus programs.
Auditing Web Site Authentication, Part One

Every web developer should read this. Excellent!
An introduction to Web Service Security using WSE - Part I - The Code Project - C++ Web Services

Some big players as Microsoft and IBM built a group that dealed with the security problem (of Web Services), finally offering several specifications. The most important, and foundation of the others, is Web Service-Security (WS-Security or WSS).

2006-03-29

SSH : Support : Cryptography A-Z

Site with a lot of information on cryptography, and different algorithms.
Visual Studio 2005: Visual Studio 2005 Code Snippets

This is very cool! Nice and free collection of code snippets from Microsoft, ready for pasting into your application source.

2006-03-28

Server-Side Asynchronous Methods for ASP.NET and WinFX - The Code Project - C# WebServices

This article describes how to make asychronous calls to a web service. This is useful when the web service has to perform some task that takes a while to complete before returning the result to the client. By making an asynchronous call, the thread of the calling process can go back into the pool and be useful for other purposes while waiting for the response.

2006-03-27

ITavisen.no | Nettet på: en helt ny måte

This article in Norwegian gives a few tips on starting out with Ajax (Asyncronous Javascript and XML).

2006-03-24

WebService Connection problems

Quote from a newsgroup (slightly modified):
"If a website (or a webservice) calls a webservice on the same server, then there is no limit on outgoing connections on the Framework. Due to this, the number of outgoing connections to the ASMX page will be huge, and for each connect that takes place, one wildcard TCP port gets used. Since there is a limit of 5000 wildcard TCP ports on the OS, pretty soon, after 5000 or so socket.Connects(), they will start failing with "unable to connect exceptions".

If the authentication is set to NTLM, then you will run into this problem sooner. This is because NTLM uses one extra connection, and after each successful request, that connection is torn down. If you are running into this, try setting "UnsafeAuthenticatedConnectionSharing=true" on the underlying HttpWebRequest
of the client."

A web service client has in .NET by default a limit of 2 connections. You can adjust this limit by putting the following into the web.config file of the client web (not sure about winforms clients, but probably you can put the same into the config file here as well):

<system.net>
<connectionmanagement>
<add maxconnection="40" address="*">
</connectionmanagement>
</system.net>
Solving "The underlying connection was closed: An unexpected error occurred on a send." (Webservices)

Jan Thielen (MVP) gives a solution to the problem of sporadic errors of type "The underlying connection was closed".

In essence, you need to add the following code to your Webreference's Reference.cs file:


protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.HttpWebRequest webRequest =
(System.Net.HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false; return webRequest;
}

2006-03-20

Caring for your introvert

This article explains why introverts are the way they are, so that maybe extroverts can understand them better.

2006-03-06

Code Generation with Codesmith

Codesmith is an excellent tool for generating general code, like for instance cargos. You don't always have to type all the boring code. Codesmith can do some of the tedious work!
Sam Gentile : No More VSS, Its Subversion

Visual Sourcesafe or as it is now known Team System is not so stable it seems. This to a degree that makes Same Gentile refer to it under the name "Unsafe" (as opposed to its real name "SourceSafe"). His team is now going for the open-source freeware Subversion source code versioning system.

2006-03-03

List of .NET 2.0 and C# 2.0 new features - The Code Project - Book Chapters

Very useful list of new features in .NET 2.0 and C" 2.0.
Ajax (programming) - Wikipedia, the free encyclopedia

Ajax is a hot buzzword these days (Asynchronous Javascript And Xml). It is a technique for making web GUIs that look more like windows forms applications (less flicker, less postback) because more operations are performed client-side.
Bamboo.Prevalence - a .NET object prevalence engine

An alternate to storing business objects in a database. Now that 64 bit CPU's are coming more and more, and they can handle much more RAM, this is probably something for now and the future. 3000 times faster than mySQL!

This is how it works:
1) All business objects are stored in RAM. 2) Once in a while a snapshot of all business objects is serialised to disk. 3) All operations on objects are stored in a log.

So what if the server crashes?
1) Restore the last snapshot.
2) Replay all actions from log.
A lot like the MS SQL Server backup / Transaction Log bacup.

2006-02-15

Request.ServerVariables("HTTP_REFERER") - What is going on?

NIS by default blocks the header "HTTP_REFERER" to be sent from the browser to the server. If your web application is depending on this servervariable, and your clients are using NIS, then do the following:

NIS:
- Privacy control - configure
- Advanced button
- Global settings tab
- "Information about visited sites"

If blocked (this appears to be the default) then HTTP-REFERER is wiped out. Change this option to allow the header to be sent.

2006-02-10

.NET Tools: Ten Must-Have Tools Every Developer Should Download Now -- MSDN Magazine, July 2004

You cannot expect to build a first-class application unless you use the best available tools. Besides well-known tools such as Visual Studio® .NET, there are a multitude of small, lesser-known tools available from the .NET community. In this article, James Avery describes some of the best free tools available today that target .NET development.

2006-02-06

FuzzyEnumParse

This function takes an Enum type and a text representing the value of the enum, and if the Enum has a field with a name contained in the text (enumText), then it returns that value.

For use when for instance the database field to parse from has been extended somewhat... Modify to suit your needs!


private object FuzzyEnumParse(System.Type type, string enumText)
{
System.Reflection.FieldInfo[] fis = type.GetFields();
foreach(System.Reflection.FieldInfo fi in fis)
{
if(fi.Name!="value__")
{
object obj=fi.GetValue(null);
if(enumText.IndexOf(obj.ToString())>-1)
{
return obj;
}
}
}
return null;
}

2006-02-01

Serialising doesn't work for read-only properties in webservices

I have been puzzled by the behavior of my webservice. I have a couple of properties in an object that is sent as a parameter to the webservice. Since these properties are not assigned directly by any code, I didn't implement a "set" method for the properies. (As it turns out: Bad mistake!)

What happened was that the values were set in the client to "true", but when the object arrived inside the webservice, the values were suddenly "false".

It turns out, if you don't implement both "get" and "set" for a property, it will not be serialised.

2006-01-19

#2413 : Why do I get non-database-related 80004005 errors?: "Request object, ASP 0104
Operation not allowed"

I got this error at a customer's after they upgraded their web servers to Windows Server 2003. The error appears when trying to upload files through the web. Turns out there is a setting in the metabase.xml file (located in the Windows\System32\inetsrv directory) called AspMaxRequestEntityAllowed, that sets the maximum filesize allowed to be uploaded. This is set very low as a default, to only 204 Kb. In Windows 2000 Server you could upload files much larger (well at or above 1 Meg anyway, I believe).

2006-01-18

Best Practices for Microsoft Business Intelligence : Checks used for remoting a query to the server

Describes different reasons why a query can not be executed on the server.

2006-01-13

Discworld Quotes

A page with lots of cool quotes from the Discworld series (Terry Prattchett).

My favorite (from "Thief of Time):
If you put a large switch in some cave somewhere, with a sign on it saying 'End-Of-The-World Switch. PLEASE DO NOT TOUCH', the paint wouldn't even have time to dry.

Another good one:
"I'll tell you, the day someone pulls the plug out of the bottom of the universe, the chain will lead all the way to Ankh-Morpork and some bugger saying, 'I just wanted to see what would happen.'"
OleDbException E_FAIL(0x80004005)

Got this message when I was trying to connect to Analysis Services:
Exception: System.Data.OleDb.OleDbException
Message: No error information available: E_FAIL(0x80004005).

Looks like the most common explanation is that one of the field names in the query is a SQL reserved word, like for instance "Name", "Size" or "Read". If you use bracketed field names this should not be a problem.
LinkD

A little comparation of the subst command and the LinkD tool. From Craig Andera's blog. Craig also published the now legendary "The last config section handler I'll ever need".

2006-01-02

MSDN TV: Special Holiday Episode III: Connecting People, Programs and Devices Using WinFX: "Special Holiday Episode III: Connecting People, Programs and Devices Using WinFX"

Don Box and Chris Anderson show how to build real applications that leverage the major components in WinFX. With rich UI, robust communication, and workflow control, they build an application that integrates with various devices laying around Don's home to demonstrate how to use WinFX together.