如何在服务器端blazor应用程序中禁用连接重载消息

时间:2020-09-28 15:11:02

标签: c# blazor blazor-server-side

我要在Asp.Net核心服务器端blazor应用程序中禁用连接重载消息吗?当服务器发生连接超时或页面空闲一段时间后,就会出现此消息。请参阅问题屏幕截图。我引用了以下链接,并在_Host.cshtml中添加了代码以解决此问题,但仍未解决。请参考以下屏幕截图。

public class Part {

public double supply(int qty) {
    if (stockLevel >= qty) {
        stockLevel -= qty;
        //System.out.println("Stock level for ID : " + ID + " is now " + stockLevel + " units.");
        return qty * unitPrice;
    } else
        return -1.0;
}
}


public class AssembledPart extends Part {

public double supply(int qty) //getID / getUnitPrice()
//override supply of Part class // returns dollar value of supplying specified qty of stock reduce stock levels appropriately to keep updated

{

    if (qty <= getStockLevel())
    {
        super.supply(qty);
        return  qty * getCost();
    } 
    else if (qty <= getStockLevel() + getAvailForAssembly())
    {
        super.supply(0);
        part0.supply(qty - getStockLevel());
        part1.supply(qty - getStockLevel());
        return qty * getCost();
    }
    else
        return -1.0;
}

}



public class PartMenu {

Part part[] = new Part[6];
Scanner scan = new Scanner(System.in);



public void supplys()
{
    System.out.print("Enter Product ID to supply : ");
    String enteredID = scan.nextLine();
    
    boolean foundID = false;
    
    for (int i = 0; i < 6; i++)
    {
        if(enteredID.equals(part[i].getID()))
        {
            if (part[i] instanceof AssembledPart)
            {
                if (part[i] instanceof AssembledPart)
                {
                    ((AssembledPart) part[i]).supply(40); // trying this on partID p184 and AssembledPart stock level remains the same.
                    System.out.println("Assembled Part");
                    System.out.println("Part ID : " + ((AssembledPart) part[i]).getID());
                    System.out.println("Assembled Part Stock Level : " + ((AssembledPart) part[i]).getStockLevel());            } 
                }
            else if (part[i] instanceof Part)
            {
                ((Part) part[i]).supply(5);
                System.out.println("Part");
                System.out.println("Part ID : " + ((Part) part[i]).getID());
                System.out.println("Part Stock Level : " + ((Part) part[i]).getStockLevel());

            } 
            }}if (foundID == false) 
                System.out.println("Part ID does not exist."); 
                
}

public void createParts()
{
    
    part[0] = new Part("p101", "Crank", 218, 12.20);
    part[1] = new Part("p102", "Pedal", 320, 14.30);
    part[2] = new AssembledPart("p183", "Crank & Pedal", 80, 3.50, part[0], part[1]);
    part[3] = new Part("p103", "Handlebar", 120, 35.50);
    part[4] = new Part("p104", "Stem", 90, 20.0);
    part[5] = new AssembledPart("p184", "Handlebar & Stem", 30, 1.50, part[3], part[4]);

    for (int i = 0; i < 6; i++)
        System.out.println(part[i].getID() + ", Stock Level : " + 
                            part[i].getStockLevel());
}

public static void main(String args[])
{
    PartMenu pm = new PartMenu();
    pm.createParts();
    pm.supplys();
}

还尝试了startup.cs文件中的另一种解决方案,但未解决。

<script>
   Blazor.defaultReconnectionHandler._reconnectCallback = function(d) {
        document.location.reload(); 
   }
</script>

enter image description here

enter image description here

有人想禁用此连接重载消息吗?

0 个答案:

没有答案