when i run this web site locally, everything works fine, but when i move my files to the server i get the error on the User type. i tried to deploy my website, to copy my website, to create new on ftp website but nothing works, i have searched for a solution, but couldn't find any answer for my problem. can any one please help..! here is my code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class admin_login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{
User user = new User();
user.username = txtUsername.Text;
user.password = txtPassword.Text;
User login = loggInn(user);
if (login == null)
{
Label1.Text = "User name or password is wrong";
}
else
{
Session["userName"] = user.username;
Session["lastvisit"] = login.lastvisit;
Session["systemUser"] = login.role;
// Session["rolle"] = godkjent.rolle;
Response.Redirect("Default.aspx");
}
//string loggInn = checkUserLinq(user);
// string check = checkUser(user);
}
public byte[] pass(string inn)
{
var algoritme = System.Security.Cryptography.SHA1.Create();
byte[] data, utdata;
data = System.Text.Encoding.ASCII.GetBytes(inn);
utdata = algoritme.ComputeHash(data);
return utdata;
}
public User loggInn(User inn)
{
using (var db = new DataClassesDataContext())
{
byte[] passordArray;
passordArray = pass(inn.password);
try
{
var brukere = from s in db.TUsers
where s.Username == inn.username &&
s.Password == passordArray
select new User
{
username = s.Username,
email = s.Email,
role = s.Role,
lastvisit = Convert.ToDateTime(s.Lastvisit)
};
if (brukere.Count() == 0 || brukere == null)
{
return null;
}
User user = brukere.First();
char[] x = inn.username.ToCharArray();
int a = x.Length;
char[] y = user.username.ToCharArray();
for (int i = 0; i < x.Length; i++)
{
if (!y[i].Equals(x[i]))
return null;
}
return user;
}
catch (Exception err)
{
return null;
}
}
}
}
my web.config
xml version="1.0"?>
name="testdbConnectionString" connectionString="Data Source=tcp:myhost.com;Initial Catalog=testdb;User ID=testdb_user;Password=*****"
providerName="System.Data.SqlClient" />
debug="false" targetFramework="4.0">
assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
sarkaftPosted Jan 23, 2012, 2:33 AM
- right click on solution and add new project-> classlibrary (name it whatevr you want).
- add the classes to the classlibrary.
- right click on the website and go to addreferences, select the classlibrary you just created.
- add using classlibrary on the top of the .cs files.
- build the solution.
- move/copy the bin folder to the root directory.
I think it is very complicated when uploading the website to server, everything works fine locally. and after much work locally things gets hard when uploading to server.!
thanks for all the help..
Jignesh TrivediPosted Jan 23, 2012, 1:16 AM
your web site workng fine in Local Env. that means there is deployment issue on iis.
kindly check access right on linking data base.
can we know what is error desc?
hope this help.