Share via


Getting Started with Customizing a SharePoint Web Site in Visual Studio .NET

The Microsoft® Visual Studio® .NET integrated development environment (IDE) offers the premier environment for customizing a site based on Microsoft Windows® SharePoint™ Services. You need to take certain steps in order to use this environment when customizing a SharePoint Web site. These include using a specific path when creating a Web application, setting a reference to Microsoft.SharePoint.dll, and may include adding a Multipurpose Internet Mail Extensions (MIME) type in Internet Information Services (IIS).

Adding a new MIME type

Since IIS v6 disables requests to .tmp files, if you are using Visual Studio .NET Version 7.0.nnnn you need to define a MIME type in IIS before you can create a custom Web application on a SharePoint Web site through the Visual Studio .NET IDE. To define the MIME type, perform the following steps:

  • On the Windows Start menu, point to Administrative Tools and click Internet Information Services (IIS).
  • In the left pane of the Microsoft Management Console, expand the branches of the console tree.
  • Right-click Web Sites and click Properties on the shortcut menu that appears.
  • In the Web Sites Properties dialog box, select the HTTP Headers tab, and click MIME Types.
  • In the MIME Types dialog box, click New.
  • In the MIME Type dialog box, type .tmp in the Extension text box, and type common/type in the MIME type text box.
  • Click OK in each dialog box until you exit the Web Sites Properties box.

Creating a Web application

Creating a Web application in Visual Studio .NET from a remote computer involves an extra step in the procedure required for creating a Web application in Visual Studio .NET when it is installed on the server that is running Windows SharePoint Services. To create a custom Web application within the context of a SharePoint deployment, perform the following steps:

  • On the File menu, point to New and then click Project.

  • In the New Project dialog box, select Visual Basic Projects or Visual C# Projects in the Project Types box, depending on which language you prefer.

  • In the Templates box, select ASP.NET Web Application.

  • In the Location box type the following path:

    http://Server_Name/_layouts/Web_Application_Name

    This path includes the name of your server, the layouts directory (_layouts), and the name of your custom Web application. Creating the custom application in the _layouts directory makes the project accessible to all sites on the server.

    Note  To create a Web application on the administrative port of the deployment, type the following path: http://Server_Name:Administrative_Port_#/Web_Application_Name

  • Click OK.

    At this point, if you are working from a remote computer, a Web Access Failed dialog box appears, telling you that the file path does not correspond to the URL you previously specified in the New Project dialog box. Perform the following steps:

    • Under What would you like to do?, ensure that Retry using a different file share path is selected and type the following path in the Location box:

      \\Server_Name\Local_Drive$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS\Web_Application_Name

      Note  Type the following path to create an application on the administrative port: \\Server_Name:Administrative_Port_#\Local_Drive$\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\ADMIN\1033\Web_Application_Name

    • Click OK.

Setting a reference to the Windows SharePoint Services assembly

After creating a new project, add a reference to the Windows SharePoint Services assembly in order to implement Intellisense features in the Object Browser and Code Editor. The process for setting a reference varies, depending on whether you are using Visual Studio .NET on a remote computer or on the server running Windows SharePoint Services. To add a reference to the assembly, perform the following steps:

  • In Solution Explorer, right-click the References node and click Add Reference on the shortcut menu.

    If you are using Visual Studio .NET on the server, perform the following steps:

    • On the .NET tab of the Add Reference dialog box, select Windows SharePoint Services in the list of components, click Select, and then click OK.

    If you are using Visual Studio .NET on a remote computer, perform the following steps:

    • Click Browse, and in the Select Component dialog box, navigate to the Local_Drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\ISAPI folder on the server running Windows SharePoint Services. You may instead prefer to first copy Microsoft.SharePoint.dll from this folder to a local drive on the remote computer and then open this local copy of the DLL in the Select Component dialog box.
    • Select Microsoft.SharePoint.dll and then click Open.
    • In the Add Reference dialog box, click OK.

Intellisense

Within the integrated development environment of Visual Studio .NET, Intellisense features are provided for namespaces in the Windows SharePoint Services assembly once a reference has been set to this assembly. The file that provides the information used by Intellisense for Windows SharePoint Services is Microsoft.SharePoint.xml, which is installed in the Local_Drive:\\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\ISAPI folder on each front-end Web server in the deployment. For updates to this file, check the Microsoft SharePoint Products and Technologies Developer Center.