Thursday, February 17, 2011

Working around missing Visual Studio 2010 Templates

As you may or may not already know, Windows Identity Foundation SDK 3.5 does not support Visual Studio 2010.

Therefore, in order to use the Visual Studio 2010 Templates, you must install Windows Identity Foundation SDK 4.0.  Unfortunately, all of the installed Visual Studio 2010 Templates only support Microsoft.Net Framework v. 4.0.

Well, if you need to still develop Claims-aware applications for Microsoft.Net Framework v. 3.5, there is still a solution available.

These are the steps you need to follow:


  1. Install Windows Identity Foundation SDK v. 4.0 (if you have not done so already)
  2. Open Visual Studio 2010
  3. From the File menu, select New-->Web Site
  4. Select the Claims-aware ASP.NET Web Site template (.NET Framework 4 should be selected in the dropdown list)
  5. Allow Visual Studio to create the Claims-aware ASP.NET Web Site
  6. Right click on the Visual Studo Web Site project and select Property Pages
  7. Once the Property Pages dialog opens, select Build from the left hand navigation menu
  8. From the Target Framework dropdown list, select .NET Framework 3.5
  9. If you are prompted with a dialog notifying you of the Target Framework changes that need to be made, click on the Yes button
  10. Click on the OK button to close the Property Pages dialog
  11. The Target Framework change will alter the necessary settings in the Web.config file, but the changes will not be complete in order to compile the web site successfully.  Therefore, right click on the Web Site project and select Build Web Site
  12. You should now see several error messages appear in the Error List window
  13. The first few error messages can easily be resolved.  Since the SampleRequestValidator.cs file did not exist as part of the Windows Identity Foundation SDK 3.5, this file can simply be deleted.  Right click on the SampleRequestValidator.cs file contained in the App_Code directory and select Delete
  14. Next, open the Web.config file and look for the following element: <httpRuntime requestValidationType="SampleRequestValidator"/>
  15. Since the SampleRequestValidator.cs file no longer exists within the Web Site project, this element can simply be removed from the Web.config file
  16. Save your Web.config file changes
  17. Save the Web Site project
  18. Once again right click on the Visual Studio Web Site project and select Build Web Site
  19. This time, if all goes well, the Web Site project should build successfully
  20. If you want to re-use this template that you have just modified for future .Net 3.5 projects, you can download the Export Template Wizard and install it from here: http://visualstudiogallery.msdn.microsoft.com/57320b20-34a2-42e4-b97e-e615c71aca24
  21. Once this extension has been installed, you will have to re-start Visual Studio for the extension to appear
  22. Now, re-open the ASP.Net 3.5 Web Site project you modified earlier
  23. From the File menu, select Export Template as VSIX
  24. You should now be able to complete the wizard so that the Project Template will be published as a Visual Studio 2010 Extension to facilitate future re-use.
  25. If you would like to create .Net Framework 3.5-compliant Web Site projects for the ASP.Net Security Token Service Web Site, you can simply change the Target Framework version to 3.5 as indicated in steps 6-11 above.
NOTE: If you want to save all of the above effort, just search for "Windows Identity Foundation" on the Visual Studio Gallery site (http://visualstudiogallery.msdn.microsoft.com) and you might be able to find a template that you are looking for!  

2 comments:

  1. If you don't find the Claims-aware ASP.NET Web Site template in step 4, be sure yuo selected the Visual C# templates. The template is not available for Visual Basic.

    ReplyDelete