Encrypting connectionstring or any section in web.config (Codesmith, Nettiers)

We are using NetTiers templates with Codesmith tool to generate the code base for our database. The autogenerated code base uses the SQL connection string in clear text format. We realized that it is a showstopper only after our deployment team pointed it out.  To our surprise we were able to find a quick solution without having to change or edit the autogenerated code. Since NetTiers uses Microsoft Enterprise library to generate the code the inherent code uses the EntLib dataaccess layer thus paving a way to an easy implementation of encryption.

OK enough of the story, below are the steps to follow:

Go to http://www.orcsweb.com/articles/aspnetmachinekey.aspx and generate a machine key. The machine key looks something like below:

<machineKey validationKey=’9A4A4ACEB1C1B352050B73FF641FACD00756C125E256C170ACA2F307059E00D05FA3BDA8BA2BB432D88C6912E5A9D33E0A2EC55AA272959CEA075E81660D9B4B’ decryptionKey=’F1E5AFF42211D3503158EFA109704EE756EFDD996010966F’ validation=’SHA1′/>

Copy this machine key text to web.config under the system.web tag.

<?xml version=”1.0″?>
<configuration>
    <appSettings/>
    <connectionStrings/>
    <system.web>
        <machineKey validationKey=’9A4A4ACEB1C1B352050B73FF641FACD00756C125E256C170ACA2F307059E00D05FA3BDA8BA2BB432D88C6912E5A9D33E0A2EC55AA272959CEA075E81660D9B4B’ decryptionKey=’F1E5AFF42211D3503158EFA109704EE756EFDD996010966F’ validation=’SHA1′/>
    </system.web>
</configuration>

Add your connection string which has to be encrypted to the connectionStrings section.
At the command prompt, change the directory to the .NET Framework version 2.0 directory by typing the following command:

cd \WINDOWS\Microsoft.Net\Framework\v2.0.*

Run the following commands:
If your web application is hosted as a website on IIS then go with:

aspnet_regiis -pe “connectionStrings” -app “/MyApplication”
aspnet_regiis -pe “system.web/machineKey” -app “/MyApplication”

If your web application is a project in your visual studio and you have the path the website folder then go with:

aspnet_regiis -pef “connectionStrings” “C:\trunk\Dev\SampleWebApp”
aspnet_regiis -pef “system.web/machineKey” “C:\trunk\Dev\SampleWebApp”

 That is it! if you open web.config you will see the section encrypted. If you are using Enterprise library application blocks for your data access layer then you dont have to do anything else to make your project understand the encrypted stuff.

 In any other case, please read http://msdn.microsoft.com/en-us/library/dtkwfdky(VS.80).aspx for more details on how to use the encrypted stuff in your application.

SharePoint Solutions Manager or The WSP Manager

Tool Description
Here is a nifty tool which can be used to deploy, redeploy, upgrade and retract/delete the solutions in the SharePoint environment. It handles all these jobs using the object model. This tool will be definitely handy for developers for quick deployment while debugging.

Purpose
The best way to get anything or any component into SharePoint environment is by creating a WSP aka Solution file. Many tools exists to create the WSP like WSPBuilder, STSDEV and Andrew Connell’s way of doing it. Having done that the next step would be deploying the same into SharePoint environment. WSPBuilder supports deploying directly though Visual Studio but some times it could get messy. It also limits to the project you set up using WSPBuilder. This tool is built in a generic way which can be used to manage already deployed solutions and also for deploying new solutions. So given a WSP file this tool can help you get that into SharePoint environment.

I agree there is another tool SharePoint Solution Installer on codeplex but I never was happy with that as it didn’t serve the purpose many a times for me. Moreover that tools was closed to administrators.

ShareTools Solution Manager does many things which can be done with stsadm command line tool. Below are a salient list of those:

  • View existing solutions in our server environment
  • Add new solutions
  • Upgrade existing solutions either immediately or at a given time
  • Redeploy an existing solution if you have a latest WSP of the same solution
  • Retract and Delete the existing solution
  • Deploy a new solution with all the parameters used in stsadm command line tool
  • Execute the administrative timer job definitions i.e stsadm.exe -o execadmsvcjobs with a single click of the button

Currently you can take action on a single item at a time.

You can download it from: http://solutionmanager.codeplex.com/

Share InfoPath Forms Tool: Deploy InfoPath Forms as a WSP Solution

Project Description
Share InfoPath Forms Tool helps make those rigid InfoPath forms sharable in SharePoint. Deployment of InfoPath Forms was never an easy task. Unlike the traditional approach of installing as a form template using stsadm commands, this tool packages delivers a WSP easing deployment.

You can download it from: http://shareinfopathforms.codeplex.com/

Project Details
-History:
I worked on a project were we had to design and deploy around 200 InfoPath forms. And each form has code behind too. So deployment of each form through Central Admin is ruled out. The next best thing we can do was using the stsadm commands. Yes, it did helped ease our job. Thus I went ahead and I built a tool which generates and/or run those stsadm commands for a given form. This tool has been on codeplex since a long time. You can get it at: http://infopathformsinstall.codeplex.com. But then it wasn’t enough. Why?

-Why:
Why did I develop this tool then? It is because even though the stsadm commands helped me solve the problem it wasn’t the best solution. Those commands run forever to complete, its CPU intensive and boring to death. So after some hiatus I found out how easy it was install those forms as a WSP solution and that is the ‘why’ this tool is developed.

-Whom:
To whom is this tool targeted? This tool was initially developed to give it to the SharePoint administrators so that they can deploy all those forms at once. And also, they can activate those forms with a single click. Nonetheless this tool can be used by a SharePoint developer for deploying a form in the local dev environment.

-How:
How to use this tool? Please see the screen shot below. Below are steps in brief:

1. Foremost point, this tool has to be executed by placing it on the server with SharePoint/MOSS installed on it.
2. Select all the published forms from your local drive or the network shared location.
3. If you don’t want to publish few of those forms you can remove them off the list using the ‘remove form’ button below.
4. InfoPath forms may or may not have code behind. In our case all the forms has the code behind but we developed the code in such a way that all the forms point to the same DLL. So in the common settings panel in the right you have to select if your forms has code behind and if you know the path to the DLL. If not just allow the tool to find out the DLL. How does the tool find out the DLL? Read it below.
5. Firstly hit the ‘Generate Features’ button which will generate the 12 Hive/Root structure in the output folder within the project directory. You can check out those feature folders under Output/12/TEMPLATE/FEATURES/
6. Next you hit the ‘Create WSP’ which will create the WSP for all those features and place the WSP file in the Output folder.
7. You can install the WSP right from this tool but that your choice. Once you hit the ‘Install WSP’ button it will prompt you for the site collection URL.
8. Deployment is one complete process and then the next step would be to activate each form from the site collection features page. So, to avoid that you can hit the ‘Activate Features’ button which will activate all those forms which are just installed. This could be a little bit time consuming and CPU intensive.

shareipforms

Enhancements to be released
Below are the items still under development:
* Create a SharePoint form library and enable the library to inherit a form content type.
* Associate an uploaded form template with a form library.
* Other settings (remove New Folder, Open in browser etc)
* Attach Workflow to the form content type. A workflow manager is almost ready to be released. Expect next week.

Download the tool: http://shareinfopathforms.codeplex.com/

Unauthorized exception even after using SPSecurity.RunWithElevatedPrivileges

In various cases while developing custom web parts or controls for SharePoint we have to use the SPSecurity.RunWithElevatedPrivileges construct to execute some part of the code which needs elevated permissions or which cannot be run with the current user permissions. For example, updating a SPWeb object or SPList object needs elevated permissions.

If you are getting an unauhtorized access exception even after using this block then the reason could be as follows:

While using this construct: You cannot use the objects available through the Microsoft.SharePoint.SPContext.Current property. That is because those objects were created in the security context of the current user.

So the best practice for using the SPSecurity.RunWithElevatedPrivileges is to get the SPSite/SPWeb objects using the SPContext.Current and then create the SPSite and SPWeb objects seperately. See the code below:

 

SPSite siteColl = SPContext.Current.Site;
SPWeb site = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate() {
  using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID)) {
    using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID)) {
        //Code to execute
    }
  }
});

The following code is wrong:

SPSecurity.RunWithElevatedPrivileges(delegate() {
    SPSite siteColl =    SPContext.Current.Site;
    SPWeb site = SPContext.Current.Web;
 //Code to execute

});

InfoPath Managed Form Templates Deployment Tool for SharePoint

This tool is an effort towards helping all those who are working on InfoPath Forms with SharePoint. It helps to upload/install, re-install, upgrade a form template with just a click of the button. The tool also can help in generating a script/batch file so that you can run it manually later on. Also, the tool has ‘Feature Management’ addon, using which you can see a list of activated and deactivated features using a filter if needed. It also provides the ability to activate, deactivate and uninstall a feature.
You can get the tool and read more about it at http://www.codeplex.com/InfoPathFormsInstall
Please let me know of the bugs and enhancements if anyone uses it.
Below is the screen shot of the tool:

InfoPath Form Template Deployer

InfoPath Form Template Deployer

InfoPath Managed Form Templates – upload status stuck or remains forever in ‘installing’ or ‘deleting’ state

The standard approach to upload any managed form template is to go to central admin and select ‘Manage form templates’ and upload the form template. The process isn’t complete, the ’status’ column should show as ‘Ready’, only then we can activate it to a site collection. Once we upload the status shows as ‘Installing’ and once the SharePoint timer job kicks in it completes the installation behind the scenes and the status is changed to ‘Ready’. The same happens with ‘Deleting’ which completes only when the timer job completes it.

This whole process is long and gruesome if we have to repeat for many forms so I posted some time back on how to use stsadm.exe script to upload/delete/update the managed form templates. That works great.

But it didn’t work for few days back, once the upload is done, the status remained as ‘Installing’ forever . I ran the ’stsadm.exe -o execadmsvcjobs’ command which forces the timer jobs to complete. Even that didn’t help. Just to get rid of the form, I opted to remove the template which changed the status column to ‘Deleting’ which remained like that forever.

I then started looking out for the reasons behind this weird behavior, and I see that either there should be a problem with the form template itself or the server farm. I ruled out the first reason because, I was not able to complete the upload process for none of the forms.

So, the problem is with the server farm, in which we have a single application server, a single front end web server and a database server. For the upload process to complete, the form template has to be propagated properly to all the servers in the farm. For this propagation, there are 2 important services which should be ON and working, they are:
SPTimerV3 and
SPAdmin
Run the following command to make sure those services are up and running on the servers in the farm:

  • net start SPTimerV3
  • net start SPAdmin

I checked the both on App and Front end servers and both those services were up and running. I was taken aback because this leads me to no where but back to the problem. After some time I ran those commands on the Database server too and I found that the SPAdmin service was not started on it. Once it is started all my form templates worked like a magic.

So just make sure the above services are up and running on not just the application and front end web servers but also on the database servers. Here is a good post which talks about the same.

UPDATE: I completely missed writing about how to undo the stalled status after uploading the form. Please follow the below instructions as per the post I mentioned above:

From Central Administration, go to the Operations page, under the Global configuration group, click on Timer Job Status.  On that page, look for timer jobs that have the name in the following formatting.  If you filename is FOO.xsn, it will look like:
Windows SharePoint Services Solution Deployment for “form-FOO.wsp”

See if there was a failure.  If so, go back a page, and go to Timer Job Definitions.  Drill down in the timer job definition that you care about and you can perform the following:

>> For the case of status stuck on “Uploading”:
1.       Try to restart the job if that is available.
2.       If restart is not available, delete the job, then attempt to upgrade again.

>> For the case of status stuck on “Upgrading”:
1.       Try to restart the job if that is available.
2.       If restart is not available, delete the job, then attempt to upgrade again.

>> For the case of status stuck on “Removing”:
1.       Try to restart the job if that is available.
2.       Else, Remove the job. (continue to step 3)
3.       Then, go back to the Manage Form Templates and try again to Remove the form template.

In simple terms, open the Timer Job Definitions and open the wsp entry you are having the problem with and delete it. Now go back to the ‘Manage Form Templates’ page and delete the problematic form template.

How To: Choose between InfoPath Browser Forms and Custom ASPX Forms

Choosing between InfoPath forms and ASPX pages, depends totally on the nature of the problems we are solving on one side and level of skill set we are investing in solving that problem on the other side. Usually, in most cases, any manager or developer would want to use InfoPath Forms part of Office 2007 because it’s quick and easy. But, as the requirements get more complex and requires more and more customization, one might feel its better to go with ASPX pages and Visual Studio 2005 and SharePoint designer. Technically, InfoPath Forms by itself is incomplete; It needs a container which is again an ASPX web form using the XmlViewer web part. If we go with custom ASPX form, then it has to be designed either using SharePoint designer or Visual Studio leveraging web parts to show the required forms. So for this, developing web parts and its complexity needs to be taken into consideration.

So, to decide on one, we may have to take the decision step by step.

  1. If the requirement is for a single form and showing data from an external data store or from within SharePoint, then going with InfoPath Forms is recommended.
  2. If it’s a single form and needs complex actions, to and fro between the form and the data store, then choosing custom aspx pages is recommended.
  3. If the requirement needs wizard kind of feature i.e. which requires user to go through multiple screens, then custom aspx is the solution.
  4. If the data submitted through the form has to be saved to multiple locations (database, SharePoint, file storage) then InfoPath Forms is a good solution.
  5. If the requirement is for designing numerous forms which are simple enough and well documented, then InfoPath Forms should be considered. InfoPath can help deliver the solution in a short time period.
  6. InfoPath browser based forms has few limitations on the repository of controls one can use. For example: combo box, master/detail view control and many advanced controls are not supported in browser based InfoPath Forms. Depending on these limitations we have to decide on InfoPath or ASPX. ASPX has no such limitations.
  7. InfoPath forms is based on XML. The form is rendered using XSLT stylesheets and the data submitted through the form is available in XML format. The data is well structured to retrieve later on and dump the data/forms in some external system. This in combination with BizTalk server is a perfect architecture for document transition through multiple levels.
  8. InfoPath forms certainly have an edge over ASPX forms as a quick and neat solution. It has some complex out of the box controls, like date picker, file attachment control, repeating sections. InfoPath forms can also have code-behind if needed to manipulate the data on the form or behind the form.
  9. ASPX can have and do everything InfoPath Forms does, with an exception of additional development effort. Apart from it, the deployment process of aspx forms is much better and easier than InfoPath Forms.

Below are some of the excerpts from few blogs I follow which provides some valuable input comparing InfoPath and ASPX forms. Below are the Pros and Cons in using InfoPath Forms:

Pros:

  • Ideal for simple forms
  • Easy to build a form – no coding involved
  • InfoPath form itself is an xml document.
  • Support versioning
  • Works very nicely with SharePoint custom workflows as a workflow association tool.
  • Fully integrated in Microsoft Office 2007 suites like Outlook e-mail messages that can be deployed as Outlook e-mail messages, so colleagues can complete forms without leaving the familiar Outlook environment.
  • Firewall friendly. InfoPath Forms Services make it easy to extend forms solutions beyond firewall because of using many different Web browsers and mobile devices.
  • InfoPath can easily convert Word documents and Excel spreadsheets to forms and build templates to work with.
  • InfoPath provides data integrity and version control for document management purposes, and add structure to information gathering by converting legacy documents to rich InfoPath form templates.
  • Design of a form is much easier in InfoPath forms with a simple drag-and-drop interface and provides support for prebuilt template parts and shared data connections.
  • Creates PDF or XPS and other important document formats and is extensible by addition of a free plug-in to install third party tools and components for document, archival and records management
  • Fully integrated with MOSS 2007 and capable of using integrated workflow management tools in Office 2007
  • Fully Web browsed technology, includes a design checker to help ensure consistency for forms.
  • Support for information rights management to help manage permission control and building a powerful document management team site.
  • Fully centralized for entire organization and enables organizations to centrally

Cons:

  • A web browser-enabled InfoPath form does not support all features of InfoPath client.
  • Inflexible — Difficult or impossible to customize (well, you can argue that you can hack the xsl file of InfoPath)
  • No support for image buttons
  • No support for html
  • No support for tree control
  • Difficult to support Forms Based Authentication
  • By default, InfoPath cannot support SharePoint web services data connections in FBA.
  • Forms Services does not support username() function in FBA. This means that InfoPath form does not recognize the current user.
  • Difficult to perform automated web test against Forms Services.
  • Difficult to support automated deployment. Basically, you have to unzip the xsn file and programmatically modify the manifest.xsf file, and zip back to the xsn file for automated publishing.
  • The way that Forms Services supports deployment of InfoPath forms is quirky – It creates SharePoint solution packages with GUID and creates features with meaningless names on the SharePoint Features folder.

Below are the blog links which talk more about this topic:

http://www.jyhuh.com/blog/archive/2008/03/02/AspNet_vs_InfoPath_Forms_Services.aspx

http://office12.blogspot.com/2007/06/infopath-web-forms-vs-aspx.html

Rapid access to 12 Hive and stsadm.exe

Every SharePoint developer needs to have quick access to the 12 Hive, 12Hive/Bin for the stsadm for various purposes in our daily development work. But, I have seen many of them never try to make this process easier. Even though this is a trivial issue, sometimes its pretty annoying. So here are a few ways to avoid those annoying moments.
(*12 Hive = C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\)

1. Add a shortcut link to the 12 Hive folder in the task bar.Just open the windows explorer and navigate to 12 Hive. Drag the left top corner icon and drop it on the task bar in the right corner. The end result is as follows:

2. Create a shortcut to the command prompt and set the default directory to the 12 Hive’s BIN directory. Add that shortcut to the quick launch bar so that it would be one click away. Even better, you can set shortcut key to open up the command prompt. Set the Target, Start in properties as following:
Shortcut to 12 Hive/BIN

3. Add the 12 Hive to your “Favorites” in the explorer window.

4. To have access to stsadm.exe command irrespective of the folder you are in. Update the “Path” environment variable to add the path to the 12 Hive/BIN folder. (Right click My Computer – Go to Advanced Tab – Click Environment Variable , under system variables, edit Path variable and append the 12Bin path using semicolon as a delimiter).

access stsadm.exe everywhere

5. This is yet another good one posted by Daniel in the comments:

“I usually create a junction point (officially a ntfs reparse point) in the file system using the junction tool from sysinternals (http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx)

junction.exe c:\wss “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\”

That gives me something like c:\wss pointing to the 12 hive and stsadm.exe under c:\wss\bin.

(I do the same for the Windows Debugging tools and create a junction for them under c:\Debug.)”

If you have any more options to make a developers life even more better and easier, please add to the comments.

InfoPath Forms – Minimize and Maximize Sections or Collapsible Sections

Recently, I have been working on a project, in which we used InfoPath extensively for designing various forms. Many of the forms has repeated information which we categorized as Header, Footer, Tracking Details etc. InfoPath template parts helped in this aspect.

Having solved that, the form still looks a little bit huge with many fields most of which are pre-populated and the user doesn’t have to worry about them. So, I thought having them collapsed initially by default and provide the user a way to maximize and minimize(collapse) the various sections would solve this issue. Something like below. See the screenshots.

At first thought, we go about searching for those tiny buttons to use for the maximize and minimize, instead there is a tricky way to do this which Microsoft uses in many windows applications. Just drop 2 buttons and put the label as 3 and 6. Now, selecting the buttons, change the font to “Marlett”, boom!, you will see the buttons changed to nice tiny triangular buttons. To make it even better, right click the button, select border/shading and select None for outline. This will merge the buttons with the background. See the below screen shots:

  1. Just put those 2 button in a single row table and place the table above the section, you want to minimize/maximize.
  2. Add a boolean field to the datasource lets say, sectionToggler. Set default to false.
  3. Open the conditional formatting settings for the section: add rules to hide it if sectionToggler = false and show it(not hide) when sectionToggler = true.
  4. Add rules on the buttons: to set the sectionToggler value to true or false depending on the button.
  5. Open up the conditional formatting settings for both the buttons and add rules to hide it based on teh sectionToggler.

More links:

  • http://blogs.msdn.com/infopath/archive/2004/06/01/145557.aspx
  • http://blogs.msdn.com/infopath/archive/2005/02/23/378968.aspx
  • http://office.microsoft.com/en-us/infopath/HA010833481033.aspx
  • http://office.microsoft.com/en-us/infopath/CH010421861033.aspx

ASP .Net tab missing or SharePoint site leading to Page not found and IIS 32/64-bit modes

Problems:

  • ASP .Net Tab Missing in the IIS Managers Website properties
  • SharePoint site shows “Page cannot be found error”.
  • SharePoint sites shows “You are not authorized to view this page”, “HTTP Error 403 – Forbidden: Access is denied.”
  • Either of the above problems in a server farm.

Possible Solutions:

There could be couple of reasons for the ASP .Net tab missing in the IIS manager. And this issue in turn could be the reason for the SharePoint site throwing the Page cannot be found or You are not authorized to view this page errors. Reasons that could be are:

  1. Improper installation of IIS and ASP .Net framework.
  2. IIS running in 32-bit mode on a 64-bit windows 2003 server.
  3. Having multiple versions of ASP .Net framework lying around on the machine which needs registry cleanup.

If your server is a 64 bit machine, then make sure your IIS is not running in 32-bit mode. For this run,

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs GET W3SVC/AppPools/Enable32bitAppOnWin64

The output tells if enable32bitapponwin64 is true or false. If its true then, go ahead and run the following to disable 32 bit mode and enable 64 bit mode:

cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

If your server is a 32 – bit machine, and your ASP .Net tab is missing then, you might follow the below steps I found in this msdn blog post and KB Article from MicroSoft:

  • Manually run the install for ASP.NET: ASPNET_regiis -i
  • Register the dll for the MMC: regsvr32.exe “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mmcaspext.dll” “rundll32.exe” “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\webengine.dll”,RegisterAspNetMMC
  • From a command prompt run: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\AspNetMmcExt.dll /tlb:AspNetMMCExt.tlb
  • Change the About value in “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\SnapIns\{fedb2179-2335-48f1-aa28-5cda35a2 b36d}” from {7D23CCC6-A390-406F-AB67-2F8B7558F6F7} to {7D23CCC6-A390-406F-AB67-2F8B7558F6F6}

If you want to have just the .net framework 2.0 on the machine go cleanup the earlier versions of it in the registry. Run regedit.exe and remove all the versions other than 2.0 below these registry entries:

  • HKEY_CLASSES_ROOT\CLSID\{7D23CCC6-A390-406E-AB67-2F8B7558F6F6}\InprocServer­32
  • HKEY_CLASSES_ROOT\CLSID\{FD5CD8B1-6FE0-44F3-BBFB-65E3655B096E}\InprocServer32
  • HKEY_CLASSES_ROOT\CLSID\{FEDB2179-2335-48F0-AA28-5CDA35A2B36D}\InprocServer­32

Try to unregister the .net framework and re-register it. Depending on your machine if 32/64-bit and the asp .net version (1.1 or 2.0?):

%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -u //for uninstallation

%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i //for installation

%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -u //for uninstallation

%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i //for installation

If doing all the above doesn’t bring back the ASP .Net tab then reboot the machine.

Doing all this should at least get rid of the ‘Page cannot be found‘ error but may lead  to the authorization error.

For the 403 or the authorization error, if you get this error when you access the site using the url like http://portalsite:<port> then try access the site as http://portalsite:<port>/default.aspx. If the later is successful then try to create a new application pool and map it to the corresponding website. Otherwise delete the web application and recreate it from scratch and it should work. This blog post something similar.

To learn more about how to maintain multiple versions of .net framework on the same machine and serve various web applications , read the article from MSDN which talks specifics about the same.