Hello,
I'm haveing a problem using a control class to verfify if someone is login and if not repsond correctly.
It can't seem to import the correct namespace for the User.Identity.IsAuthentica
ted.
I'm using windows authentication.
I have read something about Page.User....no idea.
For now i have this code in regualer code behind files and it works fine. I'm not trying to get all my reusable items together and since this is code would be in almost every page it was the first on my list :)
here is the code in the class that i'm haveing a namespace problem:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls
;
using System.Data.SqlClient;
using System.Configuration;
namespace VenderRisk
{
public class Common
{
SqlConnection Conn = new SqlConnection(Configuratio
nSettings.
AppSetting
s["Connect
ionString"
]);
public Common()
{
//
// TODO: Add constructor logic here
//
}
public bool CheckLog()
{
DataTable UserTB = new DataTable();
bool HowAboutIt;
if ((User.Identity.IsAuthenti
cated) & (Request.Cookies["UserInfo
"] != null))
{
HowAboutIt = true;
return HowAboutIt;
}
else
{
SqlCommand SelRoles = new SqlCommand("SELECT Users.RecID, Users.NTLog, Users.Fname, Users.Lname, Users.Email, Users.Phone, Users.EmpID, Users.Role, LOB.LOBID FROM Users INNER JOIN LOB ON Users.LOB = LOB.LOBID WHERE (NTLog = @ID)", Conn);
SqlParameter Userparam = new SqlParameter();
Userparam.ParameterName = "@ID";
Userparam.Value = User.Identity.Name.ToStrin
g();
SelRoles.Parameters.Add(Us
erparam);
SqlDataAdapter FillRoles = new SqlDataAdapter(SelRoles);
FillRoles.Fill(UserTB);
if (UserTB.Rows.Count > 0)
{
HttpCookie cook = new HttpCookie("UserInfo");
cook.Values.Add("UserRole"
,UserTB.Ro
ws[0]["Rol
e"].ToStri
ng());
cook.Values.Add("LOBID", UserTB.Rows[0]["LOBID"].To
String());
cook.Values.Add("UserID", UserTB.Rows[0]["RecID"].To
String());
cook.Expires = DateTime.Now + TimeSpan.FromDays(1);
Response.Cookies.Add(cook)
;
}
else
{
Response.Redirect("
http://" + Request.ServerVariables["h
ttp_host"]
+ "/VenderRisk/AddUsers.aspx
");
}
}
}
}
}
Whats going on? why wont it work? it has the correct namespace and then some!
I'm also haveing a problem with Request and Response namespaces.
I think i'm just miss understanding something.
Thanks for any help.
Start Free Trial