现在的位置: 首页 > 综合 > 正文

How to enable an ASP.Net application to run on a SharePoint virtual server

2012年02月02日 ⁄ 综合 ⁄ 共 6451字 ⁄ 字号 评论关闭
Form: http://support.microsoft.com/?id=828810

SUMMARY

This article describes how to configure an ASP.NET application to run on a virtual server that is running Microsoft Windows SharePoint Services or Microsoft Office SharePoint Portal Server 2003.

MORE INFORMATION

To enable an ASP.NET application to run on a server that is running Windows SharePoint Services or SharePoint Portal Server 2003, configure an exclusion for the application path on the virtual server. The exclusion tells the server that is running SharePoint Portal Server 2003 not to intercept the request to access the virtual server and to let the Microsoft Internet Information Services (IIS) server to handle the request.

Note In Office SharePoint Server 2007, you do not have to configure an exclusion. However, you should create a virtual directory by using Internet Information Services Manager. Additionally, you should configure the virtual directory as an application. The application should have a corresponding Web.config file.

To create an exclusion for a part of the URL namespace of the virtual server, follow these steps:

1. Click Start, click Administrative Tools, and then click SharePoint Central Administration.
2. In the Virtual Server Configuration area, click Configure virtual server settings.
3. On the Virtual Server List tab, click the virtual server that you have to add the excluded paths to.
4. Under Virtual Server Management, click Define Managed Paths.
5. In the Add a New Path section, type the path that you want to exclude in the Path box.
6. Click Excluded Path, and then click OK.

Sometimes, you have to do more than just set the Excluded path. Some Web programs require that you modify the Web.config file for the server that is running Windows SharePoint Services or SharePoint Portal Server 2003. To modify the Web.config file, follow these steps:

1. On the server that is hosting the Web page that you want to configure, locate the path that was excluded from the steps that are earlier in this article. The path will be similar to the following:

drive:\inetpub\wwwroot\Excluded Path
2. Save a backup copy of the Web.config file as Web2.config.
3. Open the Web.config file.
4. Locate the <system.web> tag, and then add the following code under the tag:

<!-- Setup the PageHandlerFactory to process all requests. This will override the SharePoint HTTPHandler. -->
            <httpHandlers>
            <add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory, System.Web, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
            </httpHandlers>
            <!-- Set the trust back to Full. WSS configures a very restrictive trust policy that does not allow most applications to run correctly. -->
            <trust level="Full" originUrl="" />
            <!--
            Enable the modules that you must have for your program to run.
            If you receive the following message:
            Parser Error Message: The module '<moduleName>' is already in the program and cannot be added again
            You can remove the modules that are mentioned in the error message. The SharePoint web.config already includes the module for OutputCache and WindowsAuthentication so you do not have to add them here.
            -->
            <httpModules>
            <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
            <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/>
            <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/>
            <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/>
            <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/>
            </httpModules>
            <!-- Enable Session for the pages -->
            <pages enableSessionState="true" enableViewState="true" enableViewStateMac="true" validateRequest="false" />

5. Save the Web.config file.

For additional information about how to create a Web.config file to use with ASP.NET, click the following article number to view the article in the Microsoft Knowledge Base:

815179 (http://support.microsoft.com/kb/815179/) How to create the Web.config file for an ASP.NET application
6. Install the HTTP module that is discussed in Microsoft Knowledge Base article 887289 to look for canonicalization issues with ASP.NET. After you install the module, add the module reference to your Web.config file for your ASP.NET application that resides under an excluded path of the SharePoint Portal Server 2003 virtual server.

Note The module does not have to be added to the Web.config file that SharePoint Portal Server 2003 uses at the root of the virtual server.

To add the module reference to your ASP.NET application's Web.config file, follow these steps:

a. Open the Web.config file.
b. Locate the <httpModules> entries inside the <system.web> section that you added in step 4, and then add the following code after the last entry:

<add name="ValidatePathModule" type="Microsoft.Web.ValidatePathModule, Microsoft.Web.ValidatePathModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=eba19824f86fdadd"/>

c. Save the Web.config file.

For additional information about canonicalization issues with ASP.NET, click the following article numbers to view the articles in the Microsoft Knowledge Base:

887289 (http://support.microsoft.com/kb/887289/) HTTP module to check for canonicalization issues with ASP.NET
887459 (http://support.microsoft.com/kb/887459/) How to programmatically test for canonicalization issues with ASP.NET

Note If you do not create the exclusion for the virtual server, Windows SharePoint Services or SharePoint Portal Server 2003 will return one of the following error messages when you try to visit any one of the pages that is located on the file system:

The page cannot be found
HTTP 404 - File not found
Error
A Web Part on this Smartpage cannot be displayed because it is not registered on this site as a safe Web Part.
Troubleshoot issues with Microsoft SharePoint.

Note This problem occurs because all requests to access the virtual server are intercepted by Windows SharePoint Services or by SharePoint Portal Server 2003.

Add the following directives in the Web.config file of the Web application between the <system.web> tag and the </system.web> tag:

<!-- 
Clear out the WSS ASP.NET handler and specify the default ASP.NET handler for all pages. 
-->

<httpHandlers>
<clear />
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory, System.Web, 
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
 />
</httpHandlers>

<!-- 
Set the trust to Full. WSS configures a very restrictive trust policy that does not 
allow ASP.NET Web application to run correctly.
-->

<trust level="Full" originUrl="" />

<!-- 
Enable the session module. This can also be enabled on the WSS Web.config, 
but is not enabled by default. If you receive the following message:
Parser Error Message: The module 'Session' is already in the application 
and cannot be added again. You can remove the following 
<httpModules></httpModules> section as session is already enabled 
on the virtual server. 
--> 

<httpModules>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
</httpModules> 

<!-- Enable session state for all the pages in the Web application. --> 
<pages enableSessionState="true" enableViewState="true" 
enableViewStateMac
="true" validateRequest="false" />

抱歉!评论已关闭.