Click here to Skip to main content
15,890,336 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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>
Any suggestions like why this is happening..
Thanks in Advance.
Sreenath
Posted
Updated 23-May-11 2:50am
v2

Just a note.

This
C#
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()


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
 
Share this answer
 
Comments
thatraja 23-May-11 14:34pm    
Actually I tried to answer for this question but I cancelled that because don't want to post unsure thing. But your answer make sense.
Sergey Alexandrovich Kryukov 23-May-11 14:56pm    
Thank you very much.
Yes, it does not answer the question, but maybe OP needs to clean up some feathers first... :-)
--SA
SQL
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...?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900