Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The type or namespace name 'User' could not be found (are you missing a using directive or an assembly reference?)
- 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;
- }
- }
- }
- }
- <?xml version="1.0"?>
- <configuration>
- <connectionStrings>
- <add name="testdbConnectionString" connectionString="Data Source=tcp:myhost.com;Initial Catalog=testdb;User ID=testdb_user;Password=*****"
- providerName="System.Data.SqlClient" />
- </connectionStrings>
- <system.web>
- <compilation debug="false" targetFramework="4.0">
- <assemblies>
- <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
- </assemblies>
- </compilation>
- </system.web>
- </configuration>
Add Comment
Please, Sign In to add comment