Pages

Thursday, February 21, 2013

Asp.NET 4.o Installation Using regiis

The ASP.NET IIS Registration tool (Aspnet_regiis.exe) is used to register ASP.NET applications with Internet Information Services (IIS). This topic describes the options, syntax, and other information for using the tool.
Using the ASP.NET IIS Registration tool, you can perform tasks such as the following:
  • Register or remove the .NET Framework ASP.NET installation with IIS.
  • Create new ASP.NET application pools.
  • Display the status of all installed versions of ASP.NET.
Important noteImportant
The version of Aspnet_regiis that is included with the .NET Framework version 4 has new features and capabilities, which are summarized in the Options section. However, these features are available only when you install the .NET Framework 4 on Windows Vista, Windows Server 2008, or Windows 7. If you install the .NET Framework version 4 on any version of Windows XP or Windows Server 2003, the tool works the same as in version 3.5 and earlier of the .NET Framework. For details about how Aspnet_regiis works on Windows XP or Windows Server 2003, see ASP.NET IIS Registration Tool for the .NET Framework Version 3.5.
The .NET Framework 4 can be installed side-by-side with previous versions of the .NET Framework on a single computer. If IIS was previously enabled on the computer, the setup process for the .NET Framework automatically registers ASP.NET 4 with IIS. However, if you install the .NET Framework 4 before you enable IIS, you must run the ASP.NET IIS Registration tool in order to register the .NET Framework with IIS and create application pools that use the .NET Framework 4.
Caution noteCaution
For information about how to find the correct version of Aspnet_regiis.exe, see Finding the Correct Version of Aspnet_regiis.exe later in this document.
aspnet_regiis [options]
The i, ir, iru and enable options are typically the only options that you require in order to register ASP.NET applications with IIS.
OptionDescription
-cLegacy option that does not apply when you run applications under ASP.NET version 4. For information about how this option works with previous versions of ASP.NET, see ASP.NET IIS Registration Tool for the .NET Framework Version 3.5.
-disableOn IIS 6.0 and on IIS 7.0 running in Classic mode, disables the ASP.NET ISAPI extension. The command does not apply to IIS 7.0 in Integrated mode.
This option can be combined only with the -i, -ir, or -r options. It is not available with IIS versions earlier than IIS 6.0.
-eRemoves the client scripts for ASP.NET from the aspnet_client subdirectory of each IIS site directory.
Only the client scripts for the ASP.NET version that is associated with Aspnet_regiis.exe are removed.
-eaRemoves the client scripts for all versions of ASP.NET from the aspnet_client subdirectory of each IIS site directory.
-enableOn IIS 6.0 and on IIS 7.0 in Classic mode, option enables the ASP.NET ISAPI extension. The command does not apply to IIS 7.0 in Integrated mode.
This option can be combined only with the -i, -ir, or -r options. It is not available with IIS versions earlier than IIS 6.0 or with ASP.NET versions earlier than ASP.NET version 2.0.
-ga userGrants the specified user or group access to the IIS metabase and other directories that are used by ASP.NET. You typically use this option when you are creating a custom service account. For more information, see How to: Create a Service Account for an ASP.NET 2.0 Application.
This option is not available with ASP.NET versions earlier than ASP.NET 2.0.
For installations on Windows Vista, Windows Server 2008, or Windows 7, this option enables you to set ACLs for groups.
NoteNote
The version of Aspnet_regiis.exe that is provided in ASP.NET versions 3.5 and earlier fails when specifying a local user or group.
-iInstalls ASP.NET 4 and updates existing applications to use the ASP.NET 4 version of the application pool. It updates both the IIS Classic mode and the IIS Integrated mode handler and script mappings in the IIS metabase.
This option creates two application pools, ASP.NET v4.0 and ASP.NET v4.0 Classic. The DefaultAppPool application pool and the Classic .NETAppPool application pools are set to the .NET Framework 4 version of the CLR.
The 32-bit version of Aspnet_regiis.exe adds only 32-bit scriptmaps to the Applicationhost.config file. The 64-bit version of Aspnet_regiis.exe adds 32-bit and 64-bit scriptmaps to the Applicationhost.config file. This is done because 64-bit versions of Windows Vista, Windows Server 2008, or Windows 7 installations that have IIS 7.0 enabled will also have Windows on Windows 64-bit (WOW64) support available.
NoteNote
In the Windows Features dialog box of the operating system, the option for ASP.NET integration is not selected. (This option is in the Internet Information Services section.) The Windows Features dialog box displays only the status of ASP.NET 2.0 integration. It does not display information about version 4.
-irInstalls and registers ASP.NET 4. This option is the same as the -i option except that this option does not change the CLR version that is associated with any existing application pools.
-iruIf ASP.NET is not currently registered with IIS, performs the tasks described for -i.
If a previous version of ASP.NET is already registered with IIS, this option performs the tasks described for -ir.
-k pathThis option is not supported under Windows Vista, Windows Server 2008, or Windows 7.
For information about how this option works when you run under Windows XP or Windows Server 2003, see ASP.NET IIS Registration Tool for the .NET Framework Version 3.5.
-kn pathThis option is not supported under Windows Vista, Windows Server 2008, or Windows 7.
For information about how this option works when you run under Windows XP or Windows Server 2003, see ASP.NET IIS Registration Tool for the .NET Framework Version 3.5.
-lkLists the path and version of all IIS metabase keys where ASP.NET is mapped. This option is not supported on Windows Vista and later versions.
The keys that inherit ASP.NET scriptmaps from a parent key are not displayed.
-lvLists the status and installation path of all versions of ASP.NET that are installed on the computer.
-norestartThis option is not supported under Windows Vista, Windows Server 2008, or Windows 7.
For information about how this option works when you run under Windows XP or Windows Server 2003, see ASP.NET IIS Registration Tool for the .NET Framework Version 3.5.
-rPerforms the tasks described for -i and in addition switches all application pools to use the .NET Framework 4 CLR.
-s pathUpdates scriptmaps and application-pool assignments for the specified application and for all sub-applications.
For a non-root Web application (not W3SVC\ or W3SVC\ROOT), the application pool settings for the non-root Web application and all its sub-applications are copied to a new application pool named ASP.NET V4.0 original application pool name, and the non-root Web application is then moved to the new application pool. The new application pool has the same settings as the original application pool, except that the copy is mapped to the .NET Framework 4 CLR and has ASP.NET 4 settings.
If the new application pool ASP.NET V4.0 original application pool name already exists, the step of creating and cloning the application pool is skipped. Instead, Aspnet_regiis.exe uses the existing application pool and sets it to use the .NET Framework 4 CLR, but makes no other changes. The tool then moves the specified application and its sub-applications to the corresponding application-pool copy. Existing application-pool settings are left unchanged.
If the specified application is the Web root (W3SVC\ or W3SVC\ROOT), Aspnet_regiis.exe updates all application pools to use the .NET Framework 4 CLR and ASP.NET 4.
-sn pathPerforms the tasks described for -s, except that -sn is not recursive. Updates scriptmaps and application-pool assignments for only the specific application. No sub-applications are changed.
If the specified application is the Web root (W3SVC\ or W3SVC\ROOT), Aspnet_regiis.exe changes the application pools named DefaultAppPool, Classic .NET AppPool, ASP.NET V4.0, and ASP.NET V4.0 Classic" to use the .NET Framework 4 CLR and ASP.NET 4.
-uFor uninstallation, leaves the two 4 versions of the application pools, leaves any applications that were in the two version 4 application pools.
This option also removes the managedRuntimeVersion attribute of application pools that were mapped to the .NET Framework 4 CLR. This reverts the application pools to the IIS 7.0 default value for the runtime, which is 2.0 on Windows Vista, Windows Server 2008, or Windows 7.
The option removes all explicitly set version 4 handler and module mappings. It also removes all scriptmaps (32-bit and 64-bit), regardless of whether the 32-bit or 64-bit version of Aspnet_regiis.exe is used.
-uaFor uninstallation, leaves the two 4 versions of the application pools, and leaves any applications that were in the two version 4 application pools.
This option removes all ASP.NET registrations (both versions 2.0 and 4) from the Applicationhost.config file. It also removes all scriptmaps (32-bit and 64-bit), regardless of whether the 32-bit or 64-bit version of Aspnet_regiis.exe is used.
Existing application pools will still be associated with the .NET Framework 2.0, because that is the default value for the managedRuntimeVersion attribute.
-?Displays the command syntax and options for the ASP.NET IIS Registration tool.

Configuration Options

OptionDescription
-config+Enables remote access to ASP.NET configuration.
-config-Disables remote access to ASP.NET configuration.
-pa container accountGrants permission for the specified user or group account to access the specified key container. This option can take the following modifiers:
  • -pku Substitutes a user-specified container for the default machine container.
  • -csp provider Specifies the container provider to use.
  • -full Specifies that full access should be added (by default, access is read-only).
-pc containerCreates an RSA public/private key pair in the specified container. This option can take the following modifiers:
  • -size keySize Specifies the key size. The default is 2048 bytes.
  • -pku Substitutes a user-specified container for the default key container.
  • -exp Specifies that private keys must be able to be exported.
  • -csp provider Specifies the container provider to use.
-pd sectionDecrypts the configuration section. This argument can take the following parameters:
  • -app virtualPath Specifies that decryption should occur at the level of the included path.
  • -location subPath Specifies the subdirectory to decrypt.
  • -pkm Specifies that the Machine.config file should be decrypted instead of the Web.config file.
-pdf section webApplicationDirectoryDecrypts the specified configuration section of the Web.config file in the specified physical (not virtual) directory.
-pe sectionEncrypts the specified configuration section. This option can take the following modifiers:
  • -prov provider Specifies the encryption provider to use.
  • -app virtualPath Specifies that encryption should occur at the level of the included path.
  • -location subPath Specifies the subdirectory to encrypt.
  • -pkm Specifies that the Machine.config file should be encrypted instead of the Web.config file.
-pef section webApplicationDirectoryEncrypts the specified configuration section of the Web.config file in the specified physical (not virtual) directory.
-pi container fileImports an RSA public/private key pair to the specified container from the specified XML file. This option can take the following modifiers:
  • -pku Substitutes a user-specified container for the default machine container.
  • -exp Specifies that private keys can be exported.
  • -csp provider Specifies the container provider to use.
-pr container accountRemoves permission for the specified user or group account to access the specified key container. This option can take the following modifiers:
  • -pku Substitutes a user-specified container for the default machine container.
  • -csp provider Specifies the container provider to use.
-px container fileExports an RSA public/private key pair from the specified container to the specified XML file. This option can take the following modifiers:
  • -pku Substitutes a user-specified container for the default machine container.
  • -csp provider Specifies the container provider to use.
-pz containerDeletes the specified key container. This option can take the following modifier:
  • -pku Substitutes a user-specified container for the default machine container.
When multiple versions of ASP.NET are installed on a computer, the versions of ASP.NET are said to be running side-by-side. In this scenario, you must configure IIS to indicate which version of the ASP.NET ISAPI (aspnet_isapi.dll) should process a page in an ASP.NET application. In IIS 7.0, in both Classic and Integrated mode, the CLR version set for the application pool determines which version of ASP.NET and which associated version of the CLR are used to run an application. In IIS 6.0, a scriptmap is used to associate an application with a specific ASP.NET ISAPI version, and the ISAPI version in turn determines which version of the CLR is used to run the application.
There are 32-bit and 64-bit versions of Aspnet_regiis.exe. For Windows Vista and Windows Server 2008, you can run the 32-bit version of the tool on a 64-bit installation of IIS. This lets you run mixed 32-bit and 64-bit worker processes on the same 64-bit system. The following table lists special cases and limitations that apply when you run the 32-bit version of the tool on a 64-bit version of IIS.
IIS VersionSpecial cases for 32-bit versions of Aspnet_regiis.exe
6.0You can run the 32-bit version of Aspnet_regiis.exe under a 64-bit IIS 6.0 installation on Windows Server 2003 with the following restrictions:
  • The 32-bit version runs only if IIS has been set to run in 32-bit mode.
  • The 64-bit version runs only if IIS has been set to run in 64-bit mode.
7.0On Windows Vista, Windows Server 2008, or Windows 7, when you run the 32-bit version of Aspnet_regiis.exe under IIS 7, the tool does not automatically set the enable32BitAppOnWin64 attribute of the applicationPools element. On a default 64-bit operating system installation, with Windows on Windows 64 enabled, you can use 32-bit Aspnet_regiis.exe to configure IIS 7, but you will not be able to run any 32-bit applications, unless you explicitly change the enable32BitAppOnWin64 attribute to enable running the application in Windows on Windows 64. For more information about IIS 7.0 configuration options, see the documentation for the applicationPools element in the Applicationhost.config file.
The ASP.NET IIS Registration tool is commonly used with the -s or -sn option to remap an ASP.NET application to the version of the .NET Framework that it is associated with. Use the -s option to update an application at the specified root path and in all of its subdirectories. If you do not want applications in subdirectories to be updated, use the -sn option.
NoteNote
The path parameter refers to the root path of the application, not the physical path. For example, W3SVC/1/ROOT/SampleApp1.
You can also use the ASP.NET IIS Registration tool to view information about ASP.NET. To list the status and installation path of all of the versions of ASP.NET that are installed on your computer, use the -lv option.
The -norestart option prevents a restart of the World Wide Web Publishing Service after ASP.NET script maps are installed or updated. If you are running multiple Web sites in IIS and they are in various application pools, and if you do not want all of them to be restarted, use this option.
Any changes made using the ASP.NET tab on the Internet Information Service console application also cause all application pools to be recycled. If you want to change the ASP.NET version that an application uses without causing all application pools to be recycled, run the following two commands to change the version.
aspnet_regiis -s w3svc/<instance>/root -norestart
iisapp /a <app pool> /r
The ASP.NET IIS Registration tool can also be used to install and uninstall the linked version of ASP.NET. Use the -i option to install ASP.NET and to update the script maps of all existing ASP.NET applications. Use the -ir option to install ASP.NET without updating the script maps. To uninstall the ASP.NET version that is associated with the tool, use the -u option. If you want to uninstall all versions of ASP.NET from the computer, use the -ua option.
You can also use the ASP.NET IIS Registration tool to view information about ASP.NET. To list the status and installation path of all of the versions of ASP.NET that are installed on your computer, use the -lv option. If you want to see the paths to all of the IIS metabase keys where ASP.NET is mapped, use the -lk option.
You can use Aspnet_regiis.exe to install and remove system client-side script, such as script for client-side validation. Use the -c option to install client script for the version of ASP.NET that is associated with the tool. (Script is installed in the Aspnet_client subdirectory of each IIS site directory.) To remove the client-side script for just the ASP.NET version that is associated with the tool, use the -e option. To remove the client-side script for all installed versions of ASP.NET, use the -ea option.
When you are using impersonation and if the impersonation account does not have Read access to the IIS metabase, a COMException exception with the message "Access is denied" is thrown when you try to access DirectoryEntry. This can occur when the Code subdirectory of the application exists in the application root directory. This error can also occur when an application is mapped to a UNC share and the UNC account does not have Read access to the metabase. In both cases, running the ASP.NET IIS Registration tool with the -ga user option for the impersonation or UNC account fixes the issue.
For more information about scriptmaps and application root paths, see the IIS documentation on the Microsoft Web site.
The following command installs the ASP.NET version that is associated with the version of the ASP.NET IIS Registration tool that you are using, and updates existing ASP.NET applications. On IIS 6.0, the command updates the scriptmaps of existing ASP.NET applications that are currently mapped to an earlier version of ASP.NET. On IIS 7.0, the command updates both classic mode and integrated mode handlers in the IIS metabase. It also switches the DefaultAppPool and the Classic .NET AppPool applications pools to use the .NET Framework 4 CLR.
aspnet_regiis -i
The following command installs the ASP.NET version that is associated with the tool without updating existing applications. On IIS 7.0, the command does not update the version of the .NET Framework associated with the DefaultAppPool and Classic .NET AppPool application pools.
aspnet_regiis -ir
The following command displays the status and installation path of all versions of ASP.NET that are installed on the computer.
 
aspnet_regiis -lv
The following command updates a Web application and all of its sub-applications to use the ASP.NET version that is associated with the tool. On IIS 6.0, the scriptmaps are updated. On IIS 7.0, the application is mapped to a new application pool.
aspnet_regiis -s W3SVC/1/ROOT/SampleApp1
The following command performs the same functions as the -s command, except that it does not affect applications in subdirectories.
aspnet_regiis -sn W3SVC/1/ROOT/SampleApp1
The following command grants the specified user or group accounts access to the IIS metabase and the other directories used by ASP.NET.
 
aspnet_regiis -ga MyUserGroup W3SVC/1/ROOT/SampleApp1
Aspnet_regiis.exe is installed in the Microsoft.NET Framework directory. If the computer is running multiple .NET Framework versions side-by-side, multiple versions of the tool might be installed. The following table lists the locations where the tool is installed for different versions of the .NET Framework.
Version of .NET FrameworkLocation of Aspnet_regiis.exe file
.NET Framework version 1%windir%\.NET\Framework\v1.0.3705
.NET Framework version 1.1%windir%\Microsoft.NET\Framework\v1.1.4322
.NET Framework version 2.0, version 3.0, and version 3.5 (32-bit systems)%windir%\Microsoft.NET\Framework\v2.0.50727
.NET Framework version 2.0, version 3.0, and version 3.5 (64-bit systems)%windir%\Microsoft.NET\Framework64\v2.0.50727
.NET Framework version 4 (32-bit systems)%windir%\Microsoft.NET\Framework\v4.0.30319
.NET Framework version 4 (64-bit systems)%windir%\Microsoft.NET\Framework64\v4.0.30319




Chances are you need to install .NET 4 (Which will also take care of a new AppPool for you)
  1. Open your command prompt (Windows + R) and type cmd and press ENTER
    You may need to start this as an administrator if you have UAC enabled.
    To do so, locate the exe (usually you can start typing with Start Menu open), right click and select "Run as Administrator"
  2. Type cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\ and press ENTER.
  3. Type aspnet_regiis.exe -ir and press ENTER again.
    • If this is a fresh version of IIS (no other sites running on it) or you're not worried about the hosted sites breaking with a framework change you can use -i instead of -ir. This will change their AppPools for you and steps 5-on shouldn't be necessary.
    • at this point you will see it begin working on installing .NET's framework in to IIS for you
  4. Close the DOS prompt, re-open your start menu and right click Computer and select Manage
  5. Expand the left-hand side (Services and Applications) and select Internet Information Services
    • You'll now have a new applet within the content window exclusively for IIS.
  6. Expand out your computer and locate the Application Pools node, and select it. (You should now see ASP.NET v4.0 listed)
  7. Expand out your Sites node and locate the site you want to modify (select it)
  8. To the right you'll notice Basic Settings... just below the Edit Site text. Click this, and a new window should appear
  9. Select the .NET 4 AppPool using the Select... button and click ok.
  10. Restart the site, and you should be good-to-go.
(You can repeat steps 7-on for every site you want to apply .NET 4 on as well).

 

Wednesday, February 20, 2013

HOW TO SETUP ASP.NET V1.1 (VISUAL STUDIO .NET 2003) PROJECTS ON IIS7 (VISTA)


Note: Although you can get Visual Studio .NET 2003 to work properly on Vista, Microsoft does not support this scenario. "Not supported" doesn't mean "won't work". It just means if you run into any trouble you just can't call the MS support line for assistance with this issue. Microsoft does, however, fully support *running* a .NET v1.1 app on Vista.

Because I support both IIS and ASP.NET here at Microsoft, I find it necessary to have both "Visual Studio .NET 2003" and "Visual Studio 2005" installed. I need to be able effectively troubleshoot issues for whatever product our customers need help with. But like any other tech junky, I like to have the latest-and-greatest OS installed so that I can learn the various features of the OS through day-to-day use. For this reason, I have Windows Vista installed on my primary machine. But, particularly when I was less familiar with the IIS 7.0 UI, getting ASP.NET 1.1 to run on IIS 7.0 was frustrating. Here are some of the errors I encountered while trying to get this setup:

Microsoft Development Environment
Error while trying to run project: Unable to start debugging on the web server. Could not start ASP.NET or ATL Server debugging.
Verify that ASP.NET or ATL Server is correctly installed on the server.

Microsoft Developement Environment
Error while trying to run project: Unable to start debugging on the web server. You do not have permissions to debug the server.
Verify that you are a member of the "Debugger Users" group on the server.

ASP.NET Version Mismatch
Visual Studio .NET has detected that the Web server is running ASP.NET version 1.0. The Web application you are creating or opening can be configured to be compliant with ASP.NET 1.0.
However, the application will not be able to use new features from ASP.NET 1.1.

To set this up properly so the above errors don't occur, follow these steps.
1. Ensure that .NET 1.1 --->SP1<--- or higher is properly installed.
  1. Vista does not include .NET v1.1 by default.
  2. Because .NET 1.1 is not included by default, .NET v1.1 *SP1* is also not included.
  3. Without SP1, W3WP.exe will crash when running an appPool under v1.1 due to DEP
  4. To check this, make sure thatc:\Windows\Microsoft.NET\Framework\v1.1.4322\mscorsvr.dllis version 1.1.4322.2032 or higher.
  5. Unless you are 100% sure that SP1 for .NET is installed, you*really* should double-check this.
  
2. Enable IIS 6.0 compatibility
  1. Open Control Panel
  2. Double-click Programs and Features
  3. Expand Internet Information Services
  4. Expand Web Management Tools
  5. Check IIS 6 Management Compatibility
  
3. Register v1.1 with IIS
  1. Open a CMD prompt
  2. Change your directory toc:\Windows\MIcrosoft.net\Framework\v1.1.4322
  3. Run "aspnet_regiis -ir"
  4. "ir" registers v1.1 with IIS but doesn't change any existing script mappings
  5. aspnet_regiis should also create a new AppPool under "Application Pools" called "ASP.NET 1.1" that is configured with the "Classic" pipline, and "Enable32BitAppOnWin64" set to true if a 64-bit OS.
  
4. Make sure IIS permits running ASP.NET.
  1. Open the IIS manager. 
  2. Highlight your Computer Name.
  3. Double-click ISAPI and CGI Restrictions
  4. Select ASP.NET v1.1.4322
  5. Click Allow in the Actions section in the upper right.

  
5. Make the new ASP.NET 1.1 appPool the default.
  1. Open the IIS manager
  2. Select the Sites folder.
  3. Under Actions on the upper right, click Set Web Site Defaults...
  4. Change the Application Pool setting to ASP.NET 1.1

  
6. **ALTERNATIVE step to 5** - Change the AppPool to ASP.NET 1.1 -->after<-- creating the ASP.NET project instead of making it the default.
  1. Create the v1.1 ASP.NET project via Visual Studio. Attempting to run the project at this point will fail if the 1.1 appPool is not the default.
  2. Open the IIS manager.
  3. Right-click the newly create application directory and chooseAdvanced Settings
  4. Change the Application Pool to ASP.NET 1.1
  5. Go back to Visual Studio and attempt to run/debug project.

Tuesday, February 19, 2013

Converting a Web Site Project to a Web Application Project



Differences between Web Site Projects (WSP) and Web Application Projects (WAP) are highlighted in blogs such as this one. Based on that, if you feel a WAP would be better for your particular needs than a WSP, but have already created a WSP, you may be asking yourself, “Can I convert my WSP into a WAP, without starting from scratch?”.
This posting explains how to convert an existing Web Site Project to a Web Application Project in Visual Studio 2010. The most striking differences to a Web Site Project are that WAPs have a project file to include and exclude files, and compile to a single assembly.
The guidelines below include several of the basic steps detailed in the Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio. This is an excellent topic to review as it discusses some specific issues you may encounter which were discovered in previous versions of Visual Studio (VS). Please keep in mind while reading it that it is based on a WSP to WAP conversion using previous versions of Visual Studio.
Let’s get started.
Open and Verify your Visual Studio Web Site Project
Before converting your WSP to a WAP, you should open it in Visual Studio and verify that is it working correctly.  This will help prevent the need to research errors that have nothing to do with the conversion process.
  1. In the File menu, click Open Web Site.
  2. The Open Web Site dialog box is displayed.
  3. Select the project folder that you want to open, and then click Open.
  4. In the Build menu, click Build Web Site.
  5. In the Debug menu, click Start Debugging. Alternatively, you can press F5.
  6. Verify your project compiles and runs as expected
Create a new, empty Visual Studio WAP A good strategy for converting a WSP to a WAP is to create a new, blank Visual Studio Web Application Project in a separate directory, but in the same solution. This avoids changing any part of the existing Web site files. It also allows you to copy existing functionality and files into the new WAP easily, within the same Visual Studio instance.
  1. In the File menu, click Add, and then click New Project.
  2. The Add New Project dialog box is displayed.
  3. In the Installed Templates section of the Add New Project dialog box, expand the language that you want to use, and then select Web to display the Web-related templates.
  4. Select Empty ASP.NET Web Application.
  5. Type values for NameLocation, and then click OK to create the Web Application Project.
  6. After the project has been created, delete the Web.config file that is created automatically.
WSPandWAP
Set Project / Assembly References
If the WSP required additional project or assembly references, you need to add them to the WAP. You can see the list of default references associated with the new (empty) Visual Studio Web Application Project under the References node in Solution Explorer.
  1. In the Solution Explorer, make sure Show All Files is turned on.
  2. In the Solution Explorer, right-click References, and then click Add Reference.
  3. The Add Reference dialog box is displayed.
  4. Select the reference that you have already added in the Web Site Project and then click OK.
  5. Note: To help prevent errors, add references to the Web Application Project for assemblies that existed in the \bin folder of the WSP.
AddRef 
Copy and Convert the App_Code folder from the Web Site Project to the Web Application Project
In WSPs, the files in the App_Code folder are all compiled together and then referenced (automatically) as a “dll” by all other files in the WSP. In WAPs, this is not the case. All code is compiled together as one .dll. I’ve found that copying the App_Code folder over first and converting it to the WAP model helps to head off some dependency issues which could arise if one copied the entire site, converted, and then tried to compile.
  1. In the Solution Explorer, copy the entire App_Code folder from the WSP to the WAP
  2. In the Solution Explorerselect the WAP’s root node; right-click, select Convert to Web Application
  3. You will see our standard Convert to Web Application confirmation dialog.  Select “Yes” to this dialog.
  4. The App_Code folder should now be renamed to Old_App_Code folder
  5. Note: Do NOT name it back. As mentioned above, in the WAP model all code will be compiled into one assembly. At runtime, ASP.NET doesn’t know what type of project model you have created and will take anything in the “App_Code” folder and create a dynamic assembly for it, thereby causing “could not load type” exceptions as there would be duplicate types exists in two assemblies (the one for the VS web application and the one for App_Code). Learn more about why App_Code folder does not work well with WAPs.
  6. Compile the WAP
  7. If you see an error, the most likely causes are:
    1. Missing assembly reference. See the section above to add missing references to your project.
    2. Files marked with Build Action = Content instead of Build Action = Compile. Any file you want compiled should be marked as such.
    3. To set the Build Action property:
      1. Select the file in the Solution Explorer
      2. Press F4 (Brings up the File’s Property Grid)
      3. Look at the Build Action property. Change as necessary.
converttowap
Copy and Convert the remaining Files and Folders from the WSP to the WAP
Once your Old_App_Code folder is compiled (by compiling your WAP in the step above), your WAP will have an assembly in the \bin directory. This will make it easier for the remaining files you are copying over to successfully compile, especially if they reference or use code in the files contained within that folder.
  1. Select the remaining files / folders from the WSP project and copy them into the WAP.
  2. Make sure not to copy the App_Code folder again.
  3. In the Solution Explorer, right click the root node of the WAP and select Convert to Web Application.
    1. Don’t worry, this won’t affect (or try to reconvert) any files or the Old_App_Code folder you have already converted.
  4. Note: This will cause VS to automatically generate a .designer.cs (or .vb) file for each page, user-control, and master page in the project. Additionally, each .aspx/.ascx will be modified to use the ‘Codebehind’ instead of the ‘CodeFile’ attribute in the Page directive.
    1. Example of the ‘CodeFile’ to ‘Codebehind’ change
      1. WSP file:  <%@ Page Title=”Home Page” Language=”C#” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
      2. Converted WAP file:  <%@ Page Title=”Home Page” Language=”C#” Inherits=”_Default” Codebehind=”Default.aspx.cs” %>
convertedfiles
Compile your WAP After all the files have been added and converted, you should build your project again to see if there are any compilation errors. At this point, some of the most likely causes of errors are:
  1. Code files set with Build Action = Content. These should be changed to Compile. Refer to the above section.
  2. Missing project or assembly references. See above for steps for adding project or assembly references.
  3. Class name collisions. In the WSP model, each .aspx and associated codefile was compiled together as a separate, individual unit. Therefore, one could have files such as foo\widget.ascx.cs and bar\widget.ascx.cs where the classes were the same. Once these files are moved to a WAP and all compiled together, class name collisions occur with errors something like, “has multiple definitions with identical signatures”. If this occurs, unique class names should be created.
Run your WAP
After completing the above steps and you have a WAP which successfully compiles, you are ready to try running your application. One of the most common problems I’ve seen encountered is the “Unknown server tag ‘SomeTag: Control’ (as it applies to user controls and such)”. This can be corrected in one of two ways.
  1. Add or modify the register directive on the page that is using the control. This will only register it for this specific page.
    1. <%@ Register Namespace”namespace the control is in” TagPrefix=”SomeTag” Assembly=”Name of dll compiled into the \bin folder” %>
  2. Register the control in the Web.config, making it available to all pages in the project
    1. In the <pages><controls> section add the following:
    2. <add tagPrefix=”SomeTag” namespace=”namespace the control is in” assembly=” Name of dll compiled into the \bin folder” />

Tuesday, February 12, 2013

jQuery:Accordian Mouse Hover



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    //slides the element
    //with class "menu_body" when mouse is over the paragraph
      $("#secondpane p.menu_head").mouseover(function()
    { $(this).css({backgroundImage:"url(~\Images\down.png)"}
                  ).next("div.menu_body").slideDown(500).siblings("div.menu_body").slideUp("slow");
      $(this).siblings().css({backgroundImage:"url(~\Images\left.png)"
      });
       });
     });
    </script>
    <style type="text/css">
        body
        {
            margin: 10px auto;
            font: 75%/120% Verdana,Arial, Helvetica, sans-serif;
        }
        .menu
        {
            width: 150px;
        }
        .menu_head
        {
            padding: 5px 10px;
            cursor: pointer;
            position: relative;
            margin: 1px;
            font-weight: bold;
            background: #eef4d3 url(left.png) center right no-repeat;
        }
        .menu_body
        {
            display: none;
        }
        .menu_body a
        {
            display: block;
            color: #006699;
            background-color: #EFEFEF;
            padding-left: 10px;
            font-weight: bold;
            text-decoration: none;
        }
        .menu_body a:hover
        {
            color: #000000;
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
   
    <div style="float: left; margin-left: 20px;">
        <!--This is the second division of right-->
        <p>
            <strong>Places</strong>
        </p>
        <div class="menu" id="secondpane">
            <!--Code for menu starts here-->
            <p class="menu_head">
                Header-1</p>
            <div class="menu_body">
                <a href="#">Link-1</a> <a href="#">Link-2</a> <a href="#">Link-3</a>
            </div>
            <p class="menu_head">
                Header-2</p>
            <div class="menu_body">
                <a href="#">Link-1</a> <a href="#">Link-2</a> <a href="#">Link-3</a>
            </div>
            <p class="menu_head">
                Header-3</p>
            <div class="menu_body">
                <a href="#">Link-1</a> <a href="#">Link-2</a> <a href="#">Link-3</a>
            </div>
        </div>
        <!--Code for menu ends here-->
    </div>
    </form>
</body>
</html>

jQuery: Accordian OnClick


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    slides the element with class "menu_body" when
        paragraph with class "menu_head" is clicked
     $("#firstpane p.menu_head").click(function()
   { $(this).css({backgroundImage:"url(down.png)"}).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
    $(this).siblings().css({backgroundImage:"url(left.png)"});
     }); //slides the element
</script>
<style type="text/css">
        body
        {
            margin: 10px auto;
            font: 75%/120% Verdana,Arial, Helvetica, sans-serif;
        }
        .menu_list
        {
            width: 150px;
        }
        .menu_head
        {
            padding: 5px 10px;
            cursor: pointer;
            position: relative;
            margin: 1px;
            font-weight: bold;
            background: #eef4d3 url(left.png) center right no-repeat;
        }
        .menu_body
        {
            display: none;
        }
        .menu_body a
        {
            display: block;
            color: #006699;
            background-color: #EFEFEF;
            padding-left: 10px;
            font-weight: bold;
            text-decoration: none;
        }
        .menu_body a:hover
        {
            color: #000000;
            text-decoration: underline;
        }

    </style>

</head>
<body>
    <form id="form1" runat="server">
    <div style="float: left">
        <!--This is the first division of left-->
        <p>
            <strong>&nbsp;Works on clicking </strong>
        </p>
        <div id="firstpane" class="menu_list">
            <!--Code for menu starts here-->
            <p class="menu_head">
                Header-1</p>
            <div class="menu_body">
                <a href="#">Link-1</a> <a href="#">Link-2</a> <a href="#">Link-3</a>
            </div>
            <p class="menu_head">
                Header-2</p>
            <div class="menu_body">
                <a href="#">Link-1</a> <a href="#">Link-2</a> <a href="#">Link-3</a>
            </div>
            <p class="menu_head">
                Header-3</p>
            <div class="menu_body">
                <a href="#">Link-1</a> <a href="#">Link-2</a> <a href="#">Link-3</a>
            </div>
        </div>
        <!--Code for menu ends here-->
    </div>
    </div>

    </form>
</body>
</html>





Friday, February 8, 2013

1.jQuery :INTRODUCTION

jQuery Introduction

 
jQuery is a JavaScript library developed to simplify client-side scripting, event handling, and animation on client side. jQuery is very powerful making its slogan very true "Write less do more".

Reason to use jQuery

 jQuery simplifies JavaScript programming and ensures the code runs on every browser available. We can do most JavaScript code with jQuery. jQuery uses a chaining mechanism while writing code which makes it more easy to write and understand.

Including jQuery in ASP.NET

To include jQuery, first download the latest version at www.jquery.com and unzip or copy the file to the root directory of your website project (in other words, where your default.aspx, index.html, or index.php file is). Microsoft Visual studio 2010 and 2012 include jQuery by default and provide intellisense to use jQuery.
After downloading jQuery you can add this in the head of your ASP.NET page (simple or master):
<script src = 'jquery-1.7.1.min.js' type = 'text/javascript'></script>
 
 
Tip: using Google AJAX libraries to add jQuery has several advantages: decreased latency, increased parallelism, and better caching.
You can add this in head section:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" 
  type="text/javascript"></script> 
 
and missing http: isn't a mistake, that’s a helpful trick which allows using a single reference that works on both HTTP and HTTPS pages. And protocol less fetch in the jQuery library is directly from disk to browser which increases the speed bit as well .

Access ASP.NET master page control with jQuery

Ensure that if you have already included jQuery in your master page, don't include this in your content page because while rendering in browser the ASP master page and content page gets merged and the browser always executes from top to bottom.

How to access elements in master page using jQuery

Below I've put some code sample which I have used to get jQuery to find .NET controls because it is hard to find the controls due to dynamic nature and .NET controls such as Master page, login control, and GridView elements.

Solution 1 :

You can use a wild card CSS selector. It works always .
input[id$=TextBox]
 
The above line matches all HTML input elements with an ID attribute that ends with "TextBox". It will match:
<asp:TextBox ID="ctl00$TextBox" runat="server"/>< asp:TextBox ID="LaLaLaTextBox" runat="server"/>< asp:TextBox ID="HehahaTextBox" runat="server"/>

Example:
$(document).ready(function () {
     //write your code here
     var  txt =$('input[id$=TextBox2]').val();
});

Solution 2

Using clientID for an ASP.NET page. The client ID of the control won't be known until the page is produced. So you can use a predictable client id using jQuery # and ID given by you.
$('#' + '<%=label1.ClientID %>')
 
or:
 
//example -
$(document).ready(function () {
     //write your code here
     var lbltext = $('#' + '<%=lbl.ClientID %>').text();

        $('#' + '<%=TextBox4.ClientID %>').val(lbltext);

 });

Solution 3

Finding it with an attribute
$("[id$=_txtSymbol]").attr("id")
 
 
Also realize that doing attribute selector searches are fairly slow (but then ‘slow’ is relative). If you have very large documents with lots of elements and you’re doing many look ups using this function, you may run into performance issues.