Popular Posts

Friday, November 16, 2012

Easy way to create query string

Not sure why this class is not publicly available?? You have to access it using the HTTPUtility.ParaseQueryString. The cool thing is that it returns encoded URL... This prints: Name=Rahman+Mahmoodi&Location=Sydney+Australia

Code Snippet
  1.        var col = System.Web.HttpUtility.ParseQueryString(string.Empty);
  2.             col.Add("Name", "rahman mahmoodi");
  3.             col.Add("Location", "Sydney Australia");
  4.  
  5.             MessageBox.Show(col.ToString());

Google Maps - Latitude and Longitude

Google map tuts series

Google Maps - Latitude and Longitude:

'via Blog this'

Show Your Data on Google Map using C# and JavaScript - CodeProject

a way of showing google map and dynamically creating the javascript file

Show Your Data on Google Map using C# and JavaScript - CodeProject:

'via Blog this'

Wednesday, November 14, 2012

JSON C# Class Generator - Home

An open source utility that converts the Json to C# classes....


JSON C# Class Generator - Home:

'via Blog this'

json2csharp - generate c# classes from json

Excellent Json to C# converter.... eg! once the Json result is returned from the service we can use this website to convert the Json result to C# classes!!! This is absolutely Great!


json2csharp - generate c# classes from json:

'via Blog this'

Saturday, September 22, 2012

Transport Security with Certificate Authentication

Configuration for using Certificate in both Client and Service using SSL and 509 Certificate -> ClientCridentialType = Certificate

Transport Security with Certificate Authentication:

'via Blog this'

Seven simple steps to enable HTTPS on WCF WsHttp bindings - CodeProject

Configuration for HTTPs -> SSL

Seven simple steps to enable HTTPS on WCF WsHttp bindings - CodeProject: "behaviorConfiguration"

'via Blog this'
The following config file worked perfectly fine for me for hosting the WCF under HTTPs and certificates:
Code Snippet
  1. <system.serviceModel>
  2.   <services>
  3.     <service name="WCF.IIS.Deployment.ServiceApplication.MathService" behaviorConfiguration="MathServiceBehaviour">
  4.       
  5.       <endpoint address="" binding="basicHttpBinding" bindingConfiguration="SecurityByTransport" contract="WCF.IIS.Deployment.ServiceApplication.IMathService">
  6.       </endpoint>
  7.  
  8.       <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  9.       
  10.       <host>
  11.         <baseAddresses>
  12.           <add baseAddress="https://localhost/WCF.IIS.Deployment.Services/" />
  13.         </baseAddresses>
  14.       </host>
  15.  
  16.     </service>
  17.  
  18.   </services>
  19.  
  20.   <bindings>
  21.     <basicHttpBinding>
  22.       <binding name="SecurityByTransport">
  23.         <security mode="Transport">
  24.           <transport clientCredentialType="None" />
  25.         </security>
  26.       </binding>
  27.     </basicHttpBinding>
  28.   </bindings>
  29.   
  30.   <behaviors>
  31.     <serviceBehaviors>
  32.       <behavior name="MathServiceBehaviour">
  33.         <serviceMetadata httpsGetEnabled="true" />
  34.         <serviceDebug includeExceptionDetailInFaults="false" />
  35.       </behavior>
  36.     </serviceBehaviors>
  37.   </behaviors>
  38. </system.serviceModel>

Friday, August 31, 2012

Hello World With Agatha

A WCF framework that supports the Request and Response scenario with base classes and all other great stuff....

Hello World With Agatha:

'via Blog this'

Tuesday, August 28, 2012

Model Binding To A List

Submitting multiple (multiline) to controller from view - MVC

here is the trick ->

Model Binding To A List: "Non-Sequential Indices"

'via Blog this'

Wednesday, August 1, 2012

Supporting multiple submit buttons on an ASP.NET MVC view

Multiple Submit buttons within the same MVC page ...

Great one ...

Supporting multiple submit buttons on an ASP.NET MVC view:

'via Blog this'

Session variables in ASP.NET MVC - Stack Overflow

Singleton session wrapper around Session Object .... Nice but possibly not thread safe? [Serializable] public sealed class SessionSingleton { #region Singleton private const string SESSION_SINGLETON_NAME = "Singleton_502E69E5-668B-E011-951F-00155DF26207"; private SessionSingleton() { } public static SessionSingleton Current { get { if ( HttpContext.Current.Session[SESSION_SINGLETON_NAME] == null ) { HttpContext.Current.Session[SESSION_SINGLETON_NAME] = new SessionSingleton(); } return HttpContext.Current.Session[SESSION_SINGLETON_NAME] as SessionSingleton; } } #endregion public string SessionVariable { get; set; } public string SessionVariable2 { get; set; } // ... }

Session variables in ASP.NET MVC - Stack Overflow:

'via Blog this'

Sunday, July 29, 2012

ExpandoObject Class (System.Dynamic)

Wowwww ....

Creating Object dynamically at run time, add property and functions to it and remove properties and functions .... ExpandoObject!!!!

Also enables to return anonymous type cross the libraries!!!

ExpandoObject Class (System.Dynamic):

'via Blog this'

Saturday, July 28, 2012

ASP.NET MVC 3: Layouts and Sections with Razor - ScottGu's Blog

Good example of Layouts = Masterpages by Scott Gu

ASP.NET MVC 3: Layouts and Sections with Razor - ScottGu's Blog:

'via Blog this'

Using Areas in ASP.NET MVC Application

Using areas to create same View / Model / Controller structure for each sub module of a big application. By default we can not use let is say HomeController for both Finance and HR departments. To be able to do so then we need to create Area in MVC by just right clicking on folder and then selecting add new Area...

Using Areas in ASP.NET MVC Application:

'via Blog this'

Saturday, July 14, 2012

Copy As HTML extension

visual studio addin to copy code as HTML... eg for blogs etc Install the addin, select code and right click and then Export As HTML ... That is it ... here is the output:
Code Snippet
  1.  
  2.     Private Sub SetPrivateProperty(Of t)(
  3.                                              ByVal targertObject As t,
  4.                                              ByVal targetPropertyName As String,
  5.                                              ByVal targetPropertyValue As Object
  6.                                          )
  7.         Dim type As Type = targertObject.GetType
  8.         type.InvokeMember(targetPropertyName,
  9.                           BindingFlags.NonPublic Or
  10.                           BindingFlags.SetProperty Or
  11.                           BindingFlags.Instance, Nothing,
  12.                           targertObject, New Object() {targetPropertyValue})
  13.     End Sub



Copy As HTML extension:

'via Blog this'

Code alignment

Visual studio extension that enables to do Code Alignment

Code alignment:

'via Blog this'

EF 5.x DbContext Generator for VB.NET extension

DbContext and entity generator for VB.Net

EF 5.x DbContext Generator for VB.NET extension:

'via Blog this'

Thursday, July 12, 2012

.net - Is it possible to set private property via reflection - Stack Overflow

Once the class is published then we don't have any control on how it will be used,,,, even we can set the Private or protected members of the class using refelection... see below


  Private Sub SetPrivateProperty(Of t)(
                                             ByVal targertObject As t,
                                             ByVal targetPropertyName As String,
                                             ByVal targetPropertyValue As Object
                                         )
        Dim type As Type = targertObject.GetType
        type.InvokeMember(targetPropertyName,
                          BindingFlags.NonPublic Or
                          BindingFlags.SetProperty Or
                          BindingFlags.Instance, Nothing,
                          targertObject, New Object() {targetPropertyValue})
    End Sub


.net - Is it possible to set private property via reflection - Stack Overflow:

'via Blog this'

Wednesday, July 11, 2012

How to make the treeview to scroll to a Position

I had terrible issues with treeview ... eg if you want to select a node in the bottom of the treeview and scrollbars are there then treeview does not scroll to the node ... ie does not ensure the node is visible. This code worked for me:


   Private Const SB_HORZ As Integer = &H0
    Private Const SB_VERT As Integer = &H1
    Private Sub SetTreeViewScrollPos(ByRef treeView As TreeViewByRef scrollPosition As Point)
        Try
            SetScrollPos(DirectCast(treeView.Handle, IntPtr), SB_HORZ, scrollPosition.X, True)
            SetScrollPos(DirectCast(treeView.Handle, IntPtr), SB_VERT, scrollPosition.Y, True)
            If treeView.Nodes.Count > 0 Then
                Dim currentNode As TreeNode = treeView.SelectedNode
                currentNode.EnsureVisible()
            End If
        Catch ex As Exception
 
        End Try
    End Sub
 
    <DllImport("user32.dll", CharSet:=System.Runtime.InteropServices.CharSet.Auto)> _
    Public Shared Function GetScrollPos(ByVal hWnd As IntegerByVal nBar As IntegerAs Integer
 
    End Function
    <DllImport("user32.dll")> _
    Private Shared Function SetScrollPos(ByVal hWnd As IntPtrByVal nBar As IntegerByVal nPos As IntegerByVal bRedraw As BooleanAs Integer
    End Function


Justin Davis: How to control the scrollbar position in a Tree View Control:

'via Blog this'

Saturday, June 30, 2012

SQL Server Date and Time data types

SQL Server 2008 has introduced the new Date and Time data types. Now assigning a date to time data type will return only the time part of the datetime and the Date will return the Date part of the datetime ...


DECLARE @datetime AS DATETIME = getdate();
DECLARE @date AS DATE = @datetime;
DECLARE @time AS TIME = @datetime;

SELECT @date, @datetime, @time

Result is:

2012-07-01 2012-07-01 10:40:06.403 10:40:06.4030000

Or alternatively:

SELECTCONVERT(TIME,GETDATE()) AS HourMinuteSecond,CONVERT(DATE,GETDATE()AS DateOnly
GO



Or to get only the HH:MM then as follow:


DECLARE @time AS TIME(0) = @datetime; -- With zero precision so returns hh:mm







'via Blog this'

SQL Complete - Intellisense in SQL Server Management Studio

An excellent sql server addin that provides code completion. SQL Complete... Freeware

SQL Complete - Intellisense in SQL Server Management Studio:

'via Blog this'

Friday, June 29, 2012

Great deal between MS and Pluralsight.... as long as you have a windows live id and you register on websitespark website then you get 3 months of free pluralsight for free!!!
Publish Post
WebsiteSpark + Pluralsight | the pluralsight blog:

http://www.microsoft.com/web/websitespark/offers/pluralsight.aspx?WT.mc_id=ban-c-corp-loc-wss

'via Blog this'

Tuesday, June 26, 2012

VMware Communities: Guest Windows Server 2008 64bit on Host...

Issue with installing the windows server 2008 and vmwre ... looks like some options needs to be chaned in BIOS and some settings needs to be ticked in VMWare:


VMware Communities: Guest Windows Server 2008 64bit on Host...:

'via Blog this'

Wednesday, May 23, 2012

Compare two datatable using LINQ Query - CodeProject

The LINQ .Except function compares the references if you are trying to find rows that are in Table1 and not in Table2 and therefore never returns correct value. To get around this issue we need to create to tables with columns and then use them using the except:


        Dim allAccountsBrief = accounts.AsEnumerable().[Select](Function(a) New With
                                                                            {Key .AccountKey = a.Item("AccountKey").ToString()})
        Dim linkedAccountsBrief = _LinkedAccounts.AsEnumerable().[Select](Function(a) New With
                                                                            {Key .AccountKey = a.Item("AccountKey").ToString()})
 
        Dim unLinkedAccountsBrief = allAccountsBrief.Except(linkedAccountsBrief)
 
        Dim unLinkedAccountsTable = (From a In accounts.AsEnumerable
                                        Join unlnked In unLinkedAccountsBrief
                                            On a.Item("AccountKey").ToString Equals unlnked.AccountKey
                                        Select a
                                    ).CopyToDataTable


Compare two datatable using LINQ Query - CodeProject:

'via Blog this'

Monday, May 7, 2012

Pipes and filters: The IEnumerable appraoch - Ayende @ Rahien

Pipes and Filters to create a Validation infrastructure for business objects. eg before performing an action the object to be passed through a set of validation rules that are registered with Business Object and after fully passing the pipline without errors then the action should be executed: ... Possible?

Pipes and filters: The IEnumerable appraoch - Ayende @ Rahien:

'via Blog this'

Saturday, May 5, 2012

SQL SERVER – Get the List of Object Dependencies – sp_depends and information_schema.routines and sys.dm_sql_referencing_entities « SQL Server Journey with SQL Authority

Good way to find out the dependencies on an object:

SELECT referencing_schema_namereferencing_entity_name,referencing_idreferencing_class_descis_caller_dependentFROM sys.dm_sql_referencing_entities ('dbo.Person''OBJECT');GO

SQL SERVER – Get the List of Object Dependencies – sp_depends and information_schema.routines and sys.dm_sql_referencing_entities « SQL Server Journey with SQL Authority: "SELECT referencing_schema_name, referencing_entity_name,
referencing_id, referencing_class_desc, is_caller_dependent
FROM sys.dm_sql_referencing_entities ('dbo.First', 'OBJECT');
GO"

'via Blog this'

Ruslan Trifonov's blog: Sql Server 2005: Change schema for all tables

change schema of all tables in one go

Ruslan Trifonov's blog: Sql Server 2005: Change schema for all tables: "exec sp_MSforeachtable "ALTER SCHEMA new_schema TRANSFER ? PRINT '? modified' ""

'via Blog this'

How to design a unit testable domain model with Entity Framework Code First – Daniel Cazzulino's Blog

A different approach than generic repository - kzu way ;-)

How to design a unit testable domain model with Entity Framework Code First – Daniel Cazzulino's Blog:

'via Blog this'

Generic Repository for Entity Framework 4.1 « Code, Wine, and IT

An implementation of the Generic Repository:

Generic Repository for Entity Framework 4.1 « Code, Wine, and IT:

'via Blog this'

Saturday, April 7, 2012

Writing custom .NET trace listeners - CodeProject®

Creating custom TraceListener. .Net provides 3 default listerners:
1- DefaultTraceListerner
2- EventLogTraceLister
3- TextWriterTraceListern

However, we can create our own listener if needed:

Writing custom .NET trace listeners - CodeProject®: "TextWriterTraceListener "

'via Blog this'

Troubleshooting Web Services

Enabling tracing and logging using web config in xml web services.


Troubleshooting Web Services: "ThrowDetailedError "

'via Blog this'

The ASP Column: Using SOAP Extensions in ASP.NET

An excellent diagram and definition of the Soap message Request/Response pipeline both in Client and Server side. The same sort of events happens both in client and server side to process the request and responses. This is where we can plug our own extensions to intercepts the messages and perform more actions eg logging, encryption, etc


The ASP Column: Using SOAP Extensions in ASP.NET:

'via Blog this'

ASMX SoapExtension to Strip out Whitespace and New Lines - Scott Hanselman

Creating Web Service ASMX custom extensions to control Request / Response pipeline ... eg create custom logging extension etc

ASMX SoapExtension to Strip out Whitespace and New Lines - Scott Hanselman:

'via Blog this'

Friday, March 30, 2012

Open source .NET and Mono web services framework

Sounds interesting. Runs in many different platforms with many end points seamlessly.
It is open source. An alternative to WCF?


Open source .NET and Mono web services framework: "Opensource "

'via Blog this'

Monday, March 19, 2012