Guest User

Untitled

a guest
Aug 5th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. The type or namespace name 'User' could not be found (are you missing a using directive or an assembly reference?)
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Data.SqlClient;
  9. using System.Data;
  10.  
  11. public partial class admin_login : System.Web.UI.Page
  12. {
  13. protected void Page_Load(object sender, EventArgs e)
  14. {
  15. Label1.Text = "";
  16. }
  17. protected void Button1_Click(object sender, EventArgs e)
  18. {
  19. User user = new User();
  20. user.username = txtUsername.Text;
  21. user.password = txtPassword.Text;
  22.  
  23. User login = loggInn(user);
  24. if (login == null)
  25. {
  26. Label1.Text = "User name or password is wrong";
  27. }
  28. else
  29. {
  30. Session["userName"] = user.username;
  31. Session["lastvisit"] = login.lastvisit;
  32. Session["systemUser"] = login.role;
  33. // Session["rolle"] = godkjent.rolle;
  34. Response.Redirect("Default.aspx");
  35. }
  36. //string loggInn = checkUserLinq(user);
  37.  
  38. // string check = checkUser(user);
  39. }
  40.  
  41. public byte[] pass(string inn)
  42. {
  43. var algoritme = System.Security.Cryptography.SHA1.Create();
  44. byte[] data, utdata;
  45. data = System.Text.Encoding.ASCII.GetBytes(inn);
  46. utdata = algoritme.ComputeHash(data);
  47. return utdata;
  48. }
  49. public User loggInn(User inn)
  50. {
  51. using (var db = new DataClassesDataContext())
  52. {
  53. byte[] passordArray;
  54. passordArray = pass(inn.password);
  55. try
  56. {
  57. var brukere = from s in db.TUsers
  58. where s.Username == inn.username &&
  59. s.Password == passordArray
  60. select new User
  61. {
  62. username = s.Username,
  63. email = s.Email,
  64. role = s.Role,
  65. lastvisit = Convert.ToDateTime(s.Lastvisit)
  66. };
  67. if (brukere.Count() == 0 || brukere == null)
  68. {
  69. return null;
  70. }
  71.  
  72. User user = brukere.First();
  73.  
  74. char[] x = inn.username.ToCharArray();
  75. int a = x.Length;
  76. char[] y = user.username.ToCharArray();
  77. for (int i = 0; i < x.Length; i++)
  78. {
  79. if (!y[i].Equals(x[i]))
  80. return null;
  81. }
  82. return user;
  83. }
  84. catch (Exception err)
  85. {
  86. return null;
  87. }
  88. }
  89. }
  90. }
  91.  
  92. <?xml version="1.0"?>
  93. <configuration>
  94. <connectionStrings>
  95. <add name="testdbConnectionString" connectionString="Data Source=tcp:myhost.com;Initial Catalog=testdb;User ID=testdb_user;Password=*****"
  96. providerName="System.Data.SqlClient" />
  97. </connectionStrings>
  98. <system.web>
  99. <compilation debug="false" targetFramework="4.0">
  100. <assemblies>
  101. <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  102. </assemblies>
  103. </compilation>
  104. </system.web>
  105. </configuration>
Add Comment
Please, Sign In to add comment