How To Use Code Behind Variable On ASPX Presentation Layer?

I am developing a new ASP.NET application and have a big question. I am using Visual Studio 2008 and SQL Server 2008, programming in C#.

On my local machine I can program my application and have it work exactly as I want it to work. But, when I publish it to the testing server in my office it has odd behavior.

I have some variables which are created in the Code-Behind and on my local machine I can reference them using a standard Response.Write to display them on the actual aspx page itself. But, when I publish the application to the server, all the places where I reference the variables using Response.Write are just blank, no error. On my local machine they show up perfect. I have double checked and both systems have the latest .NET frameworks and patches.

Any ideas?
dcolandunoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anurag ThakurTechnical ManagerCommented:
to be frank there are some configuration which are required on the server becasue security on the server is restricted but if its just a basic website then it should work
what you have explained is quite wiered and should not happen
please let us know how you have configured your website on the server or is there any special component being used in the application for which some security needs to be configured
0
dcolandunoAuthor Commented:
The server doesn't, currently, have any additional components. It is configured fairly standard. I tried a simple application just a minute ago using just a data grid to display a query on the same server. That worked with no issue. But, I have the same issue when attempting to display variables from Code Behind on that same server. But, as I said before, all the code works on my local machine.

Is there some settings I should be looking at on my Windows 2003 server in the IIS configuration somewhere maybe?
0
Anurag ThakurTechnical ManagerCommented:
if something works on your local machine then it should work on the server too - but a little configuration might be required
can you please share some more information on your applciation - instead of just printing some value from the code behind what else it does
it might be helpful if you can share your code too which is not working
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

dcolandunoAuthor Commented:
Here is the code behind contents which are working locally for me, but not on the server. For 'obvious' reasons I masked the server name and user, but they don't seem to be the problem.

Thanks again.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Configuration;
using System.Xml.Linq;
 
public partial class _Default : System.Web.UI.Page
{
    public string GetConnectionString(string str)
    {
        //variable to hold the return value
        string conn = string.Empty;
        //check if a value was provided
        if (!string.IsNullOrEmpty(str))
        {
            //name provided so search for that connection
 
            ConnectionStringSettingsCollection connections = ConfigurationManager.ConnectionStrings;
        }
        else
        {
            ConnectionStringSettingsCollection connections = ConfigurationManager.ConnectionStrings;
        }
        //return the value
        return ConfigurationManager.ConnectionStrings["CorpInfoConnectionString"].ConnectionString;
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
 
        string userid = Request.ServerVariables["AUTH_USER"];
        string domainname = "BC\\";
        string emptyspace = "";
        string displayuser = "";
 
        userid = userid.Replace(domainname, emptyspace);
        userid = userid.Trim();
 
        DataTable dt = new DataTable("User");
        dt.Columns.Add("NT_ID");
        dt.Columns.Add("lname");
        dt.Columns.Add("fname");
        dt.Columns.Add("emp_code");
 
        SqlConnection Conn = new
        SqlConnection("Data Source=***;Initial Catalog=***;Persist Security Info=True;User ID=***;Password=***");
 
        SqlCommand Comm = new SqlCommand("Select NT_ID,emp_code,fname,lname from Roles_Usrs WHERE NT_ID = '" + userid + "'", Conn);
 
        displayuser = "One More Test! Is this working now?<br><br>";
 
        Comm.Connection.Open();
 
        SqlDataReader r = Comm.ExecuteReader(CommandBehavior.CloseConnection);
 
        //Response.Write("<table border=0 align=center>");
 
        while (r.Read())
        {
            //Response.Write("<tr>");
 
            DataRow row = dt.NewRow();
            row["NT_ID"] = r["NT_ID"];
            row["lname"] = r["lname"];
            row["fname"] = r["fname"];
            row["emp_code"] = r["emp_code"];
            dt.Rows.Add(row);
 
            //Response.Write("<td>");
            Response.Write(displayuser.ToString());
            Response.Write(r.GetString(0));
            //Response.Write("</td>");
 
            //Response.Write("<td>");
            //Response.Write(r.GetString(1));
            //Response.Write("</td>");
 
            //Response.Write("<td>");
            //Response.Write(r.GetString(2));
            //Response.Write("</td>");
 
            //Response.Write("<td>");
            //Response.Write(r.GetString(3));
            //Response.Write("</td>");
 
            //Response.Write("</tr>");
 
        }
        r.Close();
        Conn.Close();
 
        //Response.Write("</table>");
    }
}

Open in new window

0
Anurag ThakurTechnical ManagerCommented:
how do you set the value of this Request.ServerVariables["AUTH_USER"];
0
dcolandunoAuthor Commented:
The 'AUTH_USER" is a standard .NET value of the currently logged in domain user.
0
dcolandunoAuthor Commented:
I have figured it out for myself, it was the server itself causing the problem. We had to go into the IIS settings to force it to use the NT Authentatication and turn off Anon access to the site.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dcolandunoAuthor Commented:
I have figured it out for myself, it was the server itself causing the problem. We had to go into the IIS settings to force it to use the NT Authentatication and turn off Anon access to the site.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.