如果我使用System.Web.Ui命名空间,则ASP.Net页第一次运行会很慢

我有一个使用C#用ASP.Net Web Form 4.0编写的Web应用程序,生产机器是带有IIS 8.5.9600.16384和SQL Server 2014的Windows Server 2012 R2。

应用程序中的每个页面运行速度很快,但是使用命名空间system.web.Ui的任何页面在我第一次打开时花费将近2分钟,然后我可以快速打开任何页面而没有问题,如果没有人打开该页面将近25分钟,问题将再次出现,我需要再等待2分钟才能再次打开它。

注意:仅在生产机器上没有此问题,而在开发机器上却没有,在开发机器上一切正常,而仅在我使用命名空间system.web.Ui时才出现此问题申请页面或整个申请。

我尝试将应用程序池中的空闲超时设置为0,例如以下示例Set idle time out example,几小时后一切都会变好,但是1天后如果没有人使用该站点,则问题是回到。

请帮助诊断和解决此问题。

前端代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h3>TestPage</h3>
</asp:Content>

后端代码:

   using System;
using System.Collections.Generic;
using System.Linq;
using system.web;
using system.web.UI;
using system.web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm1 : system.web.UI.Page
    {
        protected void Page_Load(object sender,EventArgs e)
        {
            ScriptManager.RegisterClientScriptBlock(this,this.GetType(),"AlertBox","Alert('Hello World');",true);
        }
    }
}
Jackiezhan115 回答:如果我使用System.Web.Ui命名空间,则ASP.Net页第一次运行会很慢

您只需在网页中使用JavaScript警报即可代替WebForm。

alert("Your Message");
本文链接:https://www.f2er.com/3068952.html

大家都在问