Posts

User Saved Safe URL without security risks

Often there is a need to have a url like: https://myhost/AccountStatement.aspx?accountId=0392342&Date=20111109 Unfortunately this opens a security risk. The https protects the page contents but not the URL. The URL is sent as open text. The above URL tempts hackers that may also be users of the system to try enumerating various accountId in the hope that someone has forgotten to check the access permission against the user for each account (A naive assumption is that you don’t know the account number unless you are the owner…).   One solution is to put put the data in a post back and thus take it off the URL line – unfortunately it is not friendly because it prevents a user from saving the URL for quick reference.  You can have both friendly and secure by encrypting the arguments.   If you use a Membership Provider you have a key that you can use for encrypting, using the user name or host name results in a second key so you can now well encrypt the URL Pa...

A Generic GetProperty

Bill from VisibleReality.com shipped me a generic version of the code that I forgot initially on my prior post. Here it is.   You need to include: Code Snippet using System; using System.ComponentModel; The code Code Snippet /// <summary>      /// Gets the property value.      /// </summary>      /// <typeparam name="T"> The type of the property value to get. </typeparam>      /// <param name="dataItem"> The data item. </param>      /// <param name="field"> The field. </param>      /// <param name="defaultValue"> The default value. </param>      /// <returns> The property value. </returns>      public static T GetProperty<T>( this object dataItem, string field, T defaultValue = default (T))     {        if (dataItem == null )       {          throw new ArgumentNullException ( "dataItem" );       } ...

Adding a DataDefaultField to a DropDownList

At times you want to return the default to show in an asp:DropDownList from the DataSource. Normally you have only two items: DataTextField DataValueField. I will illustrate how you can add and use a DataDefaultField (boolean) to select a specific item without needing to do any C# in the page.   The steps are: Create a class that inherits from DropDownList Add in two private variable, defaultValue, isPostBack Code Snippet public class DropDownList : System.Web.UI.WebControls. DropDownList {    private string defaultValue;    private bool isPostback ; Do an override as shown below to detect PostBacks Code Snippet protected override void RaisePostDataChangedEvent()  {    isPostback = true ;     base .RaisePostDataChangedEvent();  } Add a new Property Code Snippet public virtual string DataDefaultField { get ; set ; } Add another override (this picks up the (last) def...

Time to figure out your Christmas List Wish…

There are trial (fully functional) versions of software that I would recommend at: Typically 30 days. In your spare time you may wish to try http://www.sparxsystems.com.au/ - UML, Diagramming (Beats Visio), Sequence diagrams, State diagrams, Importing of code (JAVA,C#, SQL) etc. "Rationale Rose" at 1% of the per seat price... http://www.jetbrains.com/resharper/download/ C# code analysis http://www.devexpress.com/Downloads/Visual_Studio_Add-in/ C# http://www.mztools.com/v3/download.aspx   (FREEWARE Version available) C# http://www.telerik.com/account/free-trials/trial-product-versions/single-trial.aspx?pmvid=0&pid=717   C# http://submain.com/download/ C# You may wish to download, install and "use the beegeeves out of each for 30 days" and then send summary to your significant others…. It is good to get your Christmas Wish List in early,,,,

Linq DateTime.UtcNow and SQL DateTime Datatype

Recently I have being using SQLMetal that generates dbml and the backing code. I encountered a problem that was obtuse, apparently good code was failing to execute. The message from Linq was "Row not found or changed".   Launching SQL Profiler showed me the SQL   exec sp_executesql N ' UPDATE [WebApp].[OperationInfo] SET [WorkflowResultsID] = @p8 WHERE ([MachineVersionID] = @p0) AND ([OperationID] = @p1) AND ([ExecutionDate] = @p2) AND ([OperationType] = @p3) AND ([WorkflowResultsID] IS NULL) AND ([ConfigurationResultsID] IS NULL) AND ([SequenceResultsID] IS NULL) AND ([ExecutionGuids] IS NULL) AND ([WorkRequestID] IS NULL) AND ([LastStep] = @p4) AND ([TrafficRuleCommitStatus] = @p5) AND ([CreatedUTC] = @p6) AND ([LastModifiedUTC] = @p7) ' , N ' @p0 bigint,@p1 bigint,@p2 datetime,@p3 smallint,@p4 varchar(12),@p5 smallint,@p6 datetime,@p7 datetime,@p8 bigint ' , @p0 = 1 , @p1 = 6 , @p2 = ' 2010-08-05 09:56:47.2470000 ' , @p3 = 1 , @p4 = ...

Time to get SCIENCE into Computer Science

Yesterday while hiking I listened to BBC Discovery and they were talking about the first controlled experiments on humans done by a British Navy Surgeon, James Lind , with people suffering from scurvy.  The closing comments about the difficulty of people to keep scientific (basing decisions on hard good data and not popular belief, religious belief, anecdotes etc) struck home with me.   Often I have had a discussions about which technology paths to take and usually end up using the following criteria for my recommendations: Number of lines of code to produce (lower is better) intended results Application performance – how fast is it going to run Application scalability – can we handle bigger load Expected time to completion: Expected in a mathematical sense : Estimated Time x Probability of being correct. Maintainability of code base, which breaks down into: Availability on the market of people skilled enough to do maintenance and ...

SQL Server and Rich-Sparse Data (Real Estate) – Part I

Over the last two years I have been involved with two clients that deal with Real Estate (different market segments so no conflict of interest for me). I would describe real estate data as being sparse, rich data. The typical scenario is that the data on one house consists of MLS data and County Assessor data. In the case of SQL Server 2008R2 ,the number of fields involve quickly exceed the number of columns available in a SQL Server table (non-wide 1024 columns), but less than the number of columns of a wide table (30,000).  Wide tables were introduced in SQL Server 2008, so if you are forced to run on older versions of SQL Server the options changes.   In the case of wide tables, you are restricted to 4096 columns for Inserts, Select or Updates (despite having 30000 columns available). The wide table has a column set which is essentially an untyped XML that combines all the sparse columns [ more info ]. This means that you could use XML if you are running SQL Server 2005...