Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 1st, 2012  |  syntax: None  |  size: 2.48 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. POSTing to my ASP.NET MVC app from 3rd party site
  2. <%
  3. Response.Buffer = True
  4. response.Clear()
  5. response.contenttype="text/plain"
  6. response.write "Status=OK" & vbCRLF
  7. response.write "RedirectURL=http://www.redirectsomewhere.co.uk" & vbCRLF
  8. response.End()
  9. %>
  10.        
  11. [HttpPost]
  12. public ActionResult TestCallback()
  13. {
  14.      return View();
  15. }
  16.        
  17. @{
  18.     Response.Buffer = true;
  19.     Response.Clear();
  20.     Response.ContentType = "text/plain";
  21.     Response.Write("Status=OK" + System.Environment.NewLine);
  22.     Response.Write("RedirectURL=http://www.redirectsomewhere.co.uk" + System.Environment.NewLine);
  23.     Response.End();
  24. }
  25.        
  26. http://myipaddress/CA_UAT/Token/TestCallback
  27.        
  28. http://myipaddress/CA_UAT/Token/TestCallback.asp
  29.        
  30. Response HTTP/1.1 200 OK
  31. Source: Response
  32. HttpHeader:Server
  33. Request:User-Agent Cookie
  34. Response:Response Date Set-Cookie
  35.        
  36. [HttpPost]
  37. public string TestCallback()
  38. {
  39.   string result = "Status=OK";
  40.   result += System.Environment.NewLine;
  41.   result += "RedirectURL=http://www.redirectsomewhere.co.uk";
  42.   result += System.Environment.NewLine;
  43.   return result;
  44. }
  45.        
  46. [HttpPost]
  47. public ActionResult TestCallback()
  48. {
  49.   Response.Buffer = true;
  50.   Response.Clear();
  51.   Response.ContentType = "text/plain";
  52.   Response.Write("Status=OK" + System.Environment.NewLine);
  53.   Response.Write("RedirectURL=http://www.redirectsomewhere.co.uk" + System.Environment.NewLine);
  54.   Response.Flush();
  55.   return new EmptyResult();
  56. }
  57.        
  58. [HttpPost]
  59. public ActionResult TestCallback()
  60. {
  61.     var sb = new StringBuilder();
  62.     sb.AppendLine("Status=OK");
  63.     sb.AppendLine("RedirectURL=http://www.redirectsomewhere.co.uk");
  64.     return Content(sb.ToString(), "text/plain");
  65. }
  66.        
  67. public class ResponseViewModel
  68. {
  69.     public string Status { get; set; }
  70.     public string RedirectUrl { get; set; }
  71. }
  72.        
  73. public class StatusActionResult : ContentResult
  74. {
  75.     private readonly ResponseModel _model;
  76.     public StatusActionResult(ResponseModel model)
  77.     {
  78.         _model = model;
  79.     }
  80.  
  81.     public override void ExecuteResult(ControllerContext context)
  82.     {
  83.         var response = context.HttpContext.Response;
  84.         response.ContentType = "text/plain";
  85.         response.Write(string.Format("Status={0}{1}", _model.Status, Environment.NewLine));
  86.         response.Write(string.Format("RedirectURL={0}", _model.RedirectUrl));
  87.     }
  88. }
  89.        
  90. [HttpPost]
  91. public ActionResult TestCallback()
  92. {
  93.     var model = new ResponseModel
  94.     {
  95.         Status = "OK",
  96.         RedirectUrl = "http://www.redirectsomewhere.co.uk"
  97.     };
  98.     return new StatusActionResult(model);
  99. }