Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#submit").click(function () {
- var info = {
- Username: $("#username").val(),
- Password: $("#password").val(),
- Firstname: $("#firstname").val(),
- Lastname: $("#lastname").val(),
- Email: $("#email").val()
- };
- info = JSON.stringify(info);
- event.preventDefault();
- $.ajax({
- type: "POST",
- dataType: "json",
- async: false,
- url: "http://localhost:57207/api/User/RegisterUser",
- data: info,
- success: function(data) {
- console.log(data);
- },
- error: function(input) {
- console.log(JSON.stringify(input));
- }
- })
- });
- [System.Web.Http.HttpPost]
- public JObject RegisterUser(JObject obj)
- {
- RegisterUsers user = new RegisterUsers();
- user = JsonConvert.DeserializeObject<RegisterUsers>(((JProperty)obj.First).Name);
- var temp = DataAccessLayer.RegisterUser(user.Username, user.Password, user.Firstname, user.Lastname, user.Email, null, null);
- JObject jobj = new JObject();
- jobj.Add("output", temp.ToString());
- return jobj;
- }
- POST http://localhost:57207/api/User/RegisterUser HTTP/1.1
- Host: localhost:57207
- Connection: keep-alive
- Content-Length: 125
- Accept: text/html, */*; q=0.01
- Origin: http://evil.com/
- 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
- Content-Type: application/x-www-form-urlencoded; charset=UTF-8
- Referer: http://localhost:4400/test.html
- Accept-Encoding: gzip, deflate, br
- Accept-Language: en-US,en;q=0.8
- {"Username":"johndoe","Password":"password!!!","Firstname":"john","Lastname":"doe","Email":"johndoe@random.com"}
- HTTP/1.1 200 OK
- Cache-Control: no-cache
- Pragma: no-cache
- Content-Type: application/json; charset=utf-8
- Expires: -1
- Server: Microsoft-IIS/10.0
- Access-Control-Allow-Origin: *
- X-AspNet-Version: 4.0.30319
- X-SourceFiles: =?UTF-8?B?RDpcRGV2ZWxvcG1lbnRcVGV4dDJQaG9uaWNzXFJlc3RBUElcYXBpXFVzZXJcUmVnaXN0ZXJVc2Vy?=
- X-Powered-By: ASP.NET
- Access-Control-Allow-Origin: *
- Access-Control-Allow-Methods: GET,POST,OPTIONS
- Access-Control-Allow-Headers: Content-Type, soapaction
- Date: Wed, 08 Feb 2017 19:52:43 GMT
- Content-Length: 15
- {"output":"-1"}
- {"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