Advertisement
Guest User

Untitled

a guest
Feb 8th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. $("#submit").click(function () {
  2. var info = {
  3. Username: $("#username").val(),
  4. Password: $("#password").val(),
  5. Firstname: $("#firstname").val(),
  6. Lastname: $("#lastname").val(),
  7. Email: $("#email").val()
  8. };
  9.  
  10. info = JSON.stringify(info);
  11.  
  12. event.preventDefault();
  13. $.ajax({
  14. type: "POST",
  15. dataType: "json",
  16. async: false,
  17. url: "http://localhost:57207/api/User/RegisterUser",
  18. data: info,
  19. success: function(data) {
  20. console.log(data);
  21. },
  22. error: function(input) {
  23. console.log(JSON.stringify(input));
  24. }
  25. })
  26. });
  27.  
  28. [System.Web.Http.HttpPost]
  29. public JObject RegisterUser(JObject obj)
  30. {
  31. RegisterUsers user = new RegisterUsers();
  32. user = JsonConvert.DeserializeObject<RegisterUsers>(((JProperty)obj.First).Name);
  33. var temp = DataAccessLayer.RegisterUser(user.Username, user.Password, user.Firstname, user.Lastname, user.Email, null, null);
  34. JObject jobj = new JObject();
  35. jobj.Add("output", temp.ToString());
  36.  
  37. return jobj;
  38. }
  39.  
  40. POST http://localhost:57207/api/User/RegisterUser HTTP/1.1
  41. Host: localhost:57207
  42. Connection: keep-alive
  43. Content-Length: 125
  44. Accept: text/html, */*; q=0.01
  45. Origin: http://evil.com/
  46. User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
  47. Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  48. Referer: http://localhost:4400/test.html
  49. Accept-Encoding: gzip, deflate, br
  50. Accept-Language: en-US,en;q=0.8
  51.  
  52. {"Username":"johndoe","Password":"password!!!","Firstname":"john","Lastname":"doe","Email":"johndoe@random.com"}
  53.  
  54. HTTP/1.1 200 OK
  55. Cache-Control: no-cache
  56. Pragma: no-cache
  57. Content-Type: application/json; charset=utf-8
  58. Expires: -1
  59. Server: Microsoft-IIS/10.0
  60. Access-Control-Allow-Origin: *
  61. X-AspNet-Version: 4.0.30319
  62. X-SourceFiles: =?UTF-8?B?RDpcRGV2ZWxvcG1lbnRcVGV4dDJQaG9uaWNzXFJlc3RBUElcYXBpXFVzZXJcUmVnaXN0ZXJVc2Vy?=
  63. X-Powered-By: ASP.NET
  64. Access-Control-Allow-Origin: *
  65. Access-Control-Allow-Methods: GET,POST,OPTIONS
  66. Access-Control-Allow-Headers: Content-Type, soapaction
  67. Date: Wed, 08 Feb 2017 19:52:43 GMT
  68. Content-Length: 15
  69.  
  70. {"output":"-1"}
  71.  
  72. {"readyState":0,"status":0,"statusText":"NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:57207/api/User/RegisterUser'."}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement