在IIS 7中部署网站后,按钮未被禁用 [英] Button not getting disabled after deploying site in IIS 7

查看:83
本文介绍了在IIS 7中部署网站后,按钮未被禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经在IIS 7服务器上部署了我的站点.在某些情况下,我想禁用一个按钮.这在我的本地环境中有效,但是在IIS中部署之后,它无法正常工作.

这是我的代码.

Hi,
I have deployed my site on IIS 7 server. At certain conditions I want to disable one button. This is working at my local but after deploying it in IIS, it is not working.

Here is my code.

protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                lFnEnabledisableServiceAuthentication();
            }
            catch (Exception)
            {
            }
        }

  void lFnEnabledisableServiceAuthentication()
        {
            try
            {
                string lStrUsers = "";
                string lStrCurrentUser = "";
                lStrUsers = ConfigurationManager.AppSettings["ServiceAuthUsers"].ToString();
                lStrCurrentUser = clsGlobals.Prp_clsGlobals.mFnUpdateHostUser();
                if (lStrUsers.Trim().ToLower() == lStrCurrentUser.Trim().ToLower())
                {
                    btnInovisService.Enabled = true;
                }
                else
                {
                    btnInovisService.Enabled = false;
                }

            }
            catch (Exception)
            {
                throw;
            }
        }

<appSettings >
    <add key="ServiceAuthUsers" value="MyaccountName"/>
  </appSettings>

诸如此类的任何建议..
在此先感谢.
Sreenath

Any suggestions like why this is happening..
Thanks in Advance.
Sreenath

推荐答案

请注意.

这个
Just a note.

This
if (lStrUsers.Trim().ToLower() == lStrCurrentUser.Trim().ToLower())
{
    btnInovisService.Enabled = true;
}
    else
{
    btnInovisService.Enabled = false;
}




完全一样



is exactly the same as

btnInovisService.Enabled = lStrUsers.Trim().ToLower() == lStrCurrentUser.Trim().ToLower()



只有最后一个片段是正确的.您可以在已经为布尔值的条件下分配布尔立即数truefalse.不需要时没有任何情况.

另一个问题是使用一些立即常量,例如"ServiceAuthUsers".它使您的代码不受支持.特别是,您永远不需要常量";始终使用string.Empty.
没有这样的事件Page_Load;这只是方法的名称.提出问题时,应始终指示您正在处理诸如System.Web.UI.Page.Load(或PreLoad)之类的事件.处理程序的名称可以是任何名称.太糟糕了,您使用的是自动生成的名称,该名称违反了(好的)Microsoft命名约定. (是的,Microsoft生成的名称未通过Microsoft FxCop的检查,因为它们违反了命名约定.)您最好将所有自动生成的声明重命名为某种语义.

这本身不会帮助您解决问题.我只想指出,通过对基本编程技术的这种了解,您会遇到各种各样的麻烦.抱歉,我不想让您失望,我只是想帮助您在掌握更多困难之前提高您的基本编程技能.它将很快到来;您只需要关注它即可.

—SA



Only the last fragment is correct. You assign Boolean immediate constant true or false on condition which is already a Boolean value. There are no situation when you need it.

Another problem is using some immediate constants like "ServiceAuthUsers". It makes your code unsupportable. In particular, you never need the constant ""; always use string.Empty.
There is not such event Page_Load; this is just a name of the method. When asking questions you should always indicate that you''re handling some event like System.Web.UI.Page.Load (or PreLoad). The name of the handler can be anything. Too bad you''re using auto-generated name which violates (good) Microsoft naming conventions. (Yes, Microsoft generated names do not pass Microsoft check with FxCop as they violate the naming conventions.) You should better rename all auto-generated declaration to something semantic.

This per se won''t help you to solve your problem. I only wanted to note that with such level of understanding of basic programming techniques you can expect all kinds of troubles. Sorry, I did not want to disappoint you, I just wanted to help you to tighten up you very basic programming skills before getting to something more difficult. It will come soon; you only want to pay close attention to it.

—SA


Hi, when I solved this issue by
turning  anonymous access off but again this issue started...

http://www.c-sharpcorner.com/Forums/Thread/123890/site-deployed-in-iis-7-is-always-asking-for-username-and-pas.aspx

any remedy to get rid of this credential request...?


这篇关于在IIS 7中部署网站后,按钮未被禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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