标签在本地更新,但在Azure上加载时则不会 [英] The label is being updated locally but not when loaded on Azure

查看:80
本文介绍了标签在本地更新,但在Azure上加载时则不会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是第一次在这里发帖。我正在将一个c#程序转换为asp.net进行Web部署。我的问题是,对于上帝的爱,我无法在任何地方找到答案。我的标签,当我使用visual studio在chrome上本地运行时,更新。但是当我将它移动到Azure上的远程服务器时,标签不会更新。我有免费帐户,因此很难远程进行任何调试。其他一切都有效,就是这样。这不仅令人沮丧,而且我已经尝试了我在这个网站上看到的大部分解决方案和其他问题略有相似但没有任何问题。

Okay, this is the first time posting here. I'm converting a c# program to asp.net for web deployment. My problem is, and for the love of god I can't find an answer any where. My labels, when I run it locally on chrome using visual studio, update. But when I move it to the remote server on Azure, the labels do not get updated. I have the free account so it's hard to do any debugging remotely. Everything else works, just not this. It not only is frustrating, but I have tried most of the solutions I have seen on this site and others for problems slightly similar but nothing is working.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BoggleBoardWeb
{
    public partial class BoggleBoard : Page
    {
        static int width_ = 4;
        static int desiredLength_ = 3;
        static int desiredSeed_ = 7;
        static int divisorHeight = 0;
        static int divisorWidth = 0;
        static int scoreComp;
        static int scoreHuman;
        static Queue<Tuple<string, char>> stringValues = new Queue<Tuple<string, char>>();
        static BogglePieceGenerator generator = new BogglePieceGenerator(width_, desiredSeed_);
        static BoggleBoard_Board boardInformation = new BoggleBoard_Board(width_, generator);
        static List<string> acceptedWords = new List<string>();
        static private char[,] board2D = new char[width_, width_];
        static Lexicon lexi = new Lexicon("lexicon-clean.txt");
        //TextBox humanScoreDisplay = new TextBox();
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {
                //only call if this is the first entry.
                fillBoard();
                computerScoreDisplay.Text = scoreComp.ToString();
                humanScoreDisplay.Text = scoreHuman.ToString();
           }
            while (this.Panel1.Height.Value % width_ != 0)
            {
                this.Panel1.Height = new Unit(this.Panel1.Height.Value - 1);
            }
            //get the divisor
            divisorHeight = (int)this.Panel1.Height.Value / width_;
            divisorHeight -= 2;
            while (this.Panel1.Width.Value % width_ != 0)
            {
                this.Panel1.Width = new Unit(this.Panel1.Width.Value - 1);
            }
            divisorWidth = (int)this.Panel1.Width.Value / width_;
            divisorWidth -= 2;
            gridLayout();
            computerScoreDisplay.Text = scoreComp.ToString();
            humanScoreDisplay.Text = scoreHuman.ToString();
        }
        //makes the board to be used by the gridLayout to set all the values.
        private char[,] fillBoard()
        {
            //Panel playArea = new Panel();
            //playArea = (Panel)FindControl("playArea");
            for (int x = 0; x < width_; x++)
            {
                for (int y = 0; y < width_; y++)
                {
                    board2D[x, y] = boardInformation.getLetter(x, y);
                }
            }
            return board2D;
        }
        public BoggleBoard()
        {
            
            
            
        }
        //this makes the grid layout for the program. 
        public void gridLayout()
        {
            Button[,] grid = new Button [width_,width_]; //for width * height
            for(int height = 0; height < width_; height++)
            {
                for(int width = 0; width < width_; width++)
                {
                    grid[width, height] = new Button();
                    grid[width, height].Text = board2D[width,height].ToString();
                    grid[width, height].ID = width.ToString() + '_' + height.ToString() + '_' + "btn";
                    grid[width, height].Width = divisorWidth;
                    grid[width, height].Height = divisorHeight;
                    grid[width, height].BackColor = System.Drawing.Color.White;
                    grid[width, height].Visible = true;
                    grid[width, height].Click += new System.EventHandler(OnClick);
                    this.Panel1.Controls.Add(grid[width, height]);
                }
            }
            //this.Controls.Add(playArea);
        }
        //if the user clicks on a white square it turns red
        //else it turns red for 'selected'
        protected void OnClick(object sender, EventArgs e)
        {
            //Panel playArea = (Panel)FindControl("playArea");
            Button temp = sender as Button;
            if( temp.BackColor == System.Drawing.Color.White)
            {
                temp.BackColor = System.Drawing.Color.Red;
                stringValues.Enqueue(new Tuple<string, char>(temp.ID, temp.Text.ToCharArray()[0]));
            }
            else
            {
                //check to see if there is a way to make this dynamic so we only change the ones surronding the thing.
                Button button;
                for (int height = 0; height < width_; height++)
                {
                    for (int width = 0; width < width_; width++)
                    {
                        string locator = width.ToString() + '_' + height.ToString() + '_' + "btn";
                        button = (Button)this.Panel1.FindControl(locator.ToString());   
                        button.BackColor = System.Drawing.Color.White; 
                    }
                }
                stringValues.Clear();
            }
        }
        //Check the squares clicked to see if the user has made a word.
        protected void Check_Click(object sender, EventArgs e)
        {
            Panel playArea = (Panel)FindControl("Panel1");
            if (stringValues.Count != 0)
            {
                string stringToBeSent = new string(stringValues.Dequeue().Item2, 1);
                while (stringValues.Count != 0)
                {
                    stringToBeSent += stringValues.Dequeue().Item2;
                }
                if (stringToBeSent.Length >= desiredLength_ && !hasBeenPlayer(stringToBeSent) && lexi.wordStatus(stringToBeSent) == Lexicon.Status.WORD)
                {
                    if (boardInformation.isWordOnBoard(stringToBeSent))
                    {
                        //this.Controls.Add(humanScoreDisplay);
                        acceptedWords.Add(stringToBeSent);
                        this.humanScoreDisplay.Text = acceptedWords.Count.ToString();
                        scoreHuman = acceptedWords.Count;
                    }
                }
                //reset the buttons back to their orignal color
                Button button;
                for (int height = 0; height < width_; height++)
                {
                    for (int width = 0; width < width_; width++)
                    {
                        string locator = width.ToString() + '_' + height.ToString() + '_' + "btn";
                        button = (Button)this.Panel1.FindControl(locator.ToString());
                        button.BackColor = System.Drawing.Color.White;
                    }
                }
            }
        }
        //if the user has already selected the word do nothing
        private bool hasBeenPlayer(string wordToBeCheck)
        {
            //bool hasPlayed = false;
            foreach(string word in acceptedWords)
            {
                if(word == wordToBeCheck)
                {
                    return true;
                }
            }
            return false;
        }
       //if user clicks this then hand it to computer for the beating
       protected void doneBTN_Click(object sender, EventArgs e)
        {
            ComputerPlayer compPlayer = new ComputerPlayer(lexi);
            List<string> computerPlayedWords = compPlayer.playBoggle(boardInformation, acceptedWords, 3);
            this.computerScoreDisplay.Text = computerPlayedWords.Count.ToString();
            scoreComp = computerPlayedWords.Count;
            finishBTN.Visible = true;
        }
        //if user clicks this, then load new board and reset score
        protected void playAgain_Click(object sender, EventArgs e)
       {
            //generator = new BogglePieceGenerator(width_, desiredSeed_);
            boardInformation = new BoggleBoard_Board(width_, generator);
           board2D = new char[width_, width_];
           board2D = fillBoard();
           Button button;
            //remove all the buttons
           for (int height = 0; height < width_; height++)
           {
               for (int width = 0; width < width_; width++)
               {
                   string locator = width.ToString() + '_' + height.ToString() + '_' + "btn";
                   button = (Button)this.Panel1.FindControl(locator.ToString());
                   this.Panel1.Controls.Remove(button);
               }
           }
            //recreate all the buttons
           gridLayout();
           scoreComp = 0;
           scoreHuman = 0;
           //computerScoreDisplay.Text = "0";
          // humanScoreDisplay.Text = "0";
       }
    }
}



这里是程序背后的代码。我更频繁地添加标签然后我最初做的是看它是否是一个事件问题,它不是。仍然在本地不是远程工作。

这里是前端代码:


here is the code behind for the program. I have add the label more often then I originally did to see if maybe it was an event issue, it is not. still works locally not remotely.
here is the front end code:

<%@ Page Title= "BoogleBoard" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BoggleBoard.aspx.cs" Inherits="BoggleBoardWeb.BoggleBoard" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
        
        <asp:Panel ID="Panel1" runat="server" Height="840px" Width="840px" BorderStyle="Groove" ToolTip="Click the bottoms to move" ViewStateMode="Enabled">
        </asp:Panel>
        <asp:Button ID="checkBTN" runat="server" Text="Check Word" OnClick="Check_Click" Visible="True" Width="145px" />           
        <asp:Button ID="finishBTN" runat="server" Text="Finish" OnClick="doneBTN_Click" Visible="True" Width="116px" />
        <asp:Button ID="playAgain" runat="server" Text="Play Again" OnClick="playAgain_Click" Visible="True" Width="92px" />
        <p><asp:Label ID="humanScore" runat="server" Text="Your Score: "></asp:Label>
        <asp:Label ID="humanScoreDisplay" runat="server" Text="0" BorderStyle="Groove" CssClass="active" AssociatedControlID="checkBTN"></asp:Label></p>
        <p><asp:Label ID="ComputerScoreLabel" runat="server" Text="Computer Score: "></asp:Label>
            <asp:Label ID="computerScoreDisplay" runat="server" Text="0" BorderStyle="Groove" CssClass="active" AssociatedControlID="finishBTN"></asp:Label>
        </p>
</asp:Content>





如果其中一些看起来很粗糙,我道歉,就像我说我正在学习asp.net来帮助自己进入就业市场。我通常不会寻求帮助,但我很遗憾为什么这样做,或者在这种情况下不这样做。任何建议,帮助或反馈/信息将不胜感激。就像我说的那样,使用visual studio在我的本地机器上完美运行,而不是在azure上。我没有任何其他服务器试试这个。



谢谢,



Lee



If some of this seems rough, I apologize, like I said I'm learning asp.net to help myself in the job market. I don't normally ask for help, but I'm lost on why this is doing this, or not in this case. Any suggestions, help, or feedback/information will be greatly appreciated. Like I said this works perfectly on my local machine using visual studio, just not on azure. I do not have any other server to try this on.

Thank you,

Lee

推荐答案

我弄清楚发生了什么。单词文件没有上传,我有一个例外,但忘了添加一个扔,我知道愚蠢。但该计划现在有效。 BoggleBoard [ ^ ]如果有人想查看它。电路板和电脑播放器现在效果很好!在本地系统上找到该文件。 When it was uploaded the command HttpContext.Current.Server.MapPath(lexiconFile) would put the root directory where the website was, and not the sub directory where the text file was located.
I figured out what was going on. The word file was not being uploaded, I had an exception but forgot to add a throw, I know stupid. But the program works now. BoggleBoard[^] If any one wants to check it out. The board and computer player now works great! On the local system the file was being located. When it was uploaded the command HttpContext.Current.Server.MapPath(lexiconFile) would put the root directory where the website was, and not the sub directory where the text file was located.


这篇关于标签在本地更新,但在Azure上加载时则不会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆