Replace default IPrincipal object in ASNET

There is an easy way to override or provide IPrincipal object exposed by the System.Web.UI.Page.User property. Implement OnAuthenticate handler in the Global.asax public void WindowsAuthentication_OnAuthenticate(Object Source, WindowsAuthenticationEventArgs e) { e.User = new GenericPrincipal(e.Identity, new string[] {„Role1”, „Role2”, „Role3”}); } This way you do not have to implement RoleProvider class, just …

Simple re-use of QueryString paremetr with BindableHyperLink

When you want to use a query parameter passed to your page you’ll need litle bit of extra coding. There are few ways to accomplish that but in simple cases I like to use data binding expression just inside NavigateUrl attribute on Hyperlik’s and friends: <wc:BindableHyperLink ID=”newItem” runat=”server” Text=”Add” NavigateUrl='<%# …

Reinstall ASP.NET 2.0

When your IIS is installed after the .NET 2.0 SDK was installed, you have to prep the IIS server configuration manually or reinstall .NET SDK. To manually configura IIS use ASP.NET IIS Registration Tool (Aspnet_regiis.exe) , Running: aspnet_regiis -i, does the trick when you get [NullReferenceException: Object reference not set …

ASP.NET ignores /configuration/system.web/authorization settings

A while ago, my ASP.NET 2.0 application seemed to ignore /configuration/system.web/authorization setting and authorised everyone to have access, while it should not. Application was deployed on IIS 6.0 (Windows 2003 Standard SP), with customised application pool with domain user as app pool identity. Impersonalization was off. What was strange during …

Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.

Another of „It should just work” problems… resulting in: Login failed for user ‚(null)’. Reason: Not associated with a trusted SQL Server connection. Number: 18452 Procedure: State: 1 Severity: 14 LineNumber:0 System.Data.SqlClient.SqlException : Login failed for user ‚(null)’. Reason: Not associated with a trusted SQL Server connection. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, …