Guest User

Untitled

a guest
Feb 23rd, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. $.ajax({
  2.  
  3. type: "post",
  4. url: 'http://' + ip + '/Home/Test',
  5. dataType: 'json',
  6. data: { Email: email, Password: password, LogIn: true, DeviceID: client_device, OS: OS_Version },
  7. success: function (data) {
  8. if (data.msg === "1") {
  9. }
  10. }
  11. })
  12.  
  13. <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
  14.  
  15. <httpProtocol>
  16. <customHeaders>
  17. <add name="Access-Control-Allow-Origin" value="*" />
  18. <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS"/>
  19. <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
  20. </customHeaders>
  21. </httpProtocol>
  22.  
  23. [AllowAnonymous]
  24. public JsonResult LogIn(LogInViewModel User)
  25. { ........
  26.  
  27. public class JsonpResult : JsonResult
  28. {
  29. object data = null;
  30.  
  31. public JsonpResult()
  32. {
  33. }
  34.  
  35. public JsonpResult(object data)
  36. {
  37. this.data = data;
  38. }
  39.  
  40. public override void ExecuteResult(ControllerContext controllerContext)
  41. {
  42. if (controllerContext != null)
  43. {
  44. HttpResponseBase Response = controllerContext.HttpContext.Response;
  45. HttpRequestBase Request = controllerContext.HttpContext.Request;
  46.  
  47. string callbackfunction = Request["callback"];
  48. if (string.IsNullOrEmpty(callbackfunction))
  49. {
  50. throw new Exception("Callback function name must be provided in the request!");
  51. }
  52. Response.ContentType = "application/x-javascript";
  53. if (data != null)
  54. {
  55. JavaScriptSerializer serializer = new JavaScriptSerializer();
  56. Response.Write(string.Format("{0}({1});", callbackfunction, serializer.Serialize(data)));
  57. }
  58. }
  59. }
  60. }
  61.  
  62. $.ajax({
  63. type: "post",
  64. url: 'http://' + ip + '/Home/LogIn',
  65. jsonp: "callback",
  66. dataType: 'jsonp',
  67. data: { Email: email, Password: password, LogIn: true, DeviceID: client_device, OS: OS_Version },
  68. success: function (data) {
  69. if (data.msg === "1") {
  70. window.localStorage["email"] = email;
  71. window.localStorage["sessionid"] = data.sessionid;
  72. .................
Add Comment
Please, Sign In to add comment