概要: ASP.NET is a flexible set of tools and web development technologies that allows you to employ a number of applications based on the ASP.NET framework.

In this topic, you will learn how to configure the server-wide ASP.NET settings in Plesk.

概要

Plesk supports ASP.NET 2.0 and 4.x, as well as ASP.NET Core 2.1 and later. Most ASP.NET configuration settings that commonly need to be customized in order for ASP.NET applications to function in a desirable way can be edited through Plesk.

要配置服务器级的 ASP.NET 设置,请执行下列步骤:

  1. 登录到 Plesk

  2. Go to Tools & Settings > ASP.NET Settings (under “Applications & Databases”). The settings for different versions of ASP.NET are located under the corresponding tabs.

    image asp net settings

  3. Set up the strings that determine database connection data for ASP.NET applications which use databases:

    当您首次打开ASP.NET 配置页面时,将看到显示出常用构造的示例连接参数。您可删除这些参数并指定自己的字符串。

    • To add a string, click Add one more.
    • 要删除字符串,请单击该字符串旁的 image cross icon
  4. 创建被 ASP.NET 应用程序返回的自定义错误信息:

    • 若要设置自定义错误消息模式,请从 “自定义错误模式” 菜单中选择相应的选项:

      • 开启 - 自定义错误信息已启用。
      • 关闭 - 自定义错误信息已禁用,同时显示出详细的错误信息。
      • 仅限远程 - 仅对远程用户显示自定义错误信息,本地主机只显示 ASP. NET 错误信息。
    • To add a custom error message (which will be applied unless the Off mode was selected), enter the values in the “Custom errors” fields.

      • 状态代码 参数对导致重定向到错误页面的 HTTP 状态代码进行定义。
      • 重定向 URL 参数对错误页面的 web 地址进行定义,该错误页面将错误信息呈现给客户端。

      由于可能出现的冲突,您无法添加自定义错误消息(错误代码已存在),但是您可以为现有代码重新定义 URL。

    • 要从列表中删除自定义错误消息,请单击该消息旁的 image cross icon

  5. Configure compilation settings:

    • 设置用于动态编译文件的默认编程语言,可从 “默认网页语言” 列表中选择项目。

    • 要启用编译二进制发行代码,请将 “启用调试” 复选框保留为空。

    • 要启用编译二进制调试代码,请选中 “启用调试” 复选框。这种情况下,包含错误的源代码片断将显示在诊断页面消息中。

      注解: 在调试模式下运行应用程序会消耗内存和/或降低性能。建议在测试应用程序时使用调试模式;在部署应用程序到产品方案之前则禁用此模式。

  6. Configure encoding settings for ASP.NET applications:

    • 要设置所有传入请求采用的编码,请在 “请求编码” 字段中输入一个编码值(默认为 UTF-8)。
    • 要设置所有响应采用的编码,请在 “响应编码” 字段中输入一个编码值(默认为 Utf-8)。
    • 要设置用于解析 .aspx.asmx.asax 文件的默认编码,请在 “文件编码” 字段中输入一个编码值(默认为 Windows-1252)。
    • 要设置处理传入 web 请求时所需的默认区域性,请在 “区域性” 列表中选择相应项。
    • To set a culture which must be used by default when processing searches for a locale-dependent resource, select an appropriate item from the “UI Culture” list.
  7. Set a code access security trust level for ASP.NET applications:

    CAS 信任级别是一组应用到应用程序的功能限制。例如,低级别会限制应用程序的网络功能(如发送邮件)而完全信任级别则会移除任何限制。

    • 若要更改网站的 CAS 信任级别,请选择复选框 “允许为单个网站更改 CAS 信任级别” 。如果您没有选择该复选框,网站将会使用服务器范围的设置。或者,每个网站都可以在网站主机设置中指定自己的 CAS 信任级别。

      注解: 如果一个程序集被分配的信任级别过低,则该程序集将不能正常运行。欲了解更多有关权限层级的信息请参阅 https://msdn.microsoft.com/en-us/library/Aa302425

  8. 在 “会话设置” 字段中设置客户会话参数:

    • 要设置应用程序的默认验证模式,请从”验证模式” 列表中选择合适的选项。请注意,只要使用了 IIS 验证,就必须选择 “Windows” 验证模式。
    • 要设置会话在被放弃前的空闲时间,请在 “会话超时” 字段中输入相应的分钟数。
  9. 单击 保存 以应用所有更改。

注解: Plesk 支持独立配置 .NET framework 的不同版本。

注解: If you want to use ASP.NET Core web applications, select the “Microsoft ASP.NET Core ” component when installing Plesk. After that, you can upload your ASP.NET Core application to your web site and use it. In this case, it is recommended to switch off the ASP.NET support for your domain to save server resources. To do so, go to Websites & Domains > find the domain that will host your application > go to the “Hosting & DNS” tab > Hosting and clear the Microsoft ASP.NET checkbox.