How to make a visual studio project from an existing one

Not sure if this is the “best” way to do it, but it works great for me – incase you want to make a new visual studio project based on one you already have

• Make an empty folder in C:\……\Visual Studio 2010\Projects\Work\NewFolderHere
• Right click the existing project folder and do a tortoise SVN export to copy the application files without the old SVN entries into the path above (assuming you are using SVN)
• Then run VSPRenamer (download from on the .sln file, that will do all the renaming correctly for all references within your solution
• Rename the new .sln file to match the folder
• Manually copy over the nuget packages folder to remove the yellow warning triangles from the application references so it compiles again finding your package source files

That pretty much covers my needs… you might have another couple of things but this should do the majority of the work for you, you can then work with your new solution separately

Custom membershipProvider in MVC3 and encrypt ConnectionStrings section in web.config

So it’s 10pm, and I think I finally cracked it… thanks to this tutorial I suspect I have tied an MVC3 application to a small set of credential fields in an existing database table on SQL Server.. I need to get away from the bloat of the default SQL membership and role provider structures..

The next issue will be working out if the hash between the existing web based application that uses the table I have integrated with now and the hash of my one are compatible… I will leave that until tomorrow.

On a separate note a great presentation I saw on my iPad this week was from here
where Adam Tuliper discusses web application security including some nice open source addons to make MVC less vulnerable to XSS attacks and SQL injection amongst other things. One thing that stood out as nice and simple, but essential was how easy he makes it to encrypt a section of web.config, see the screenshot from the video below. Essentially the first statement encrypts, and the second one will decrypt on the same machine, (the machine identifier is used in the algorithm so can’t be decrypted on another machine (unless you are uber cracker))..

Later this week… integrating a 3D secure payment provider to my MVC3 application… interesting days!

Set parameter value of SqlDataSource to SelectedValue of another page control

You have a DetailsView control with edit / add and all the other goodness enabled, but when adding a new record you want a non-visible field to get it’s value from another control like the SelectedValue of a GridView or a DropDownList in the InsertParameters collection of your SqlDataSource just use a ControlParameter instead

[codesyntax lang="csharp"]

    <asp:ControlParameter ControlID="ddlYourList" Name="ParameterName"
        PropertyName="SelectedValue" Type="Int32" />
    <asp:Parameter Name="SomeDetailsViewParameter" Type="String" />