.getJSON cross domain request 500 errorhttp://forums.asp.net/t/1789329.aspx/1?+getJSON+cross+domain+request+500+errorSat, 07 Apr 2012 07:26:17 -040017893294916763http://forums.asp.net/p/1789329/4916763.aspx/1?+getJSON+cross+domain+request+500+error.getJSON cross domain request 500 error <p>I am passing a basic function into a view on a different machine. I want to return a view from different url and pass in my data somehow and get a returned view with the strongly typed model inside.</p> <p>I am partially through the issue, but it comes down to getting an actionresult to render a different actionresult.</p> <p>something like, www.mypublicapp.com/abc/def would be the actionresult that I would pass my data using a &#36;.toJSON. I get a 500 error on get command. How can I fix this?</p> 2012-04-04T21:26:24-04:004916784http://forums.asp.net/p/1789329/4916784.aspx/1?Re+getJSON+cross+domain+request+500+errorRe: .getJSON cross domain request 500 error <p>What's the server error?</p> <p></p> 2012-04-04T21:51:53-04:004918250http://forums.asp.net/p/1789329/4918250.aspx/1?Re+getJSON+cross+domain+request+500+errorRe: .getJSON cross domain request 500 error <pre class="prettyprint">Error:</pre> <pre class="prettyprint">GET http://ws-xxx/previewJsonP/?callback=jQuery15105377634419128299_1333636959724&amp;htmlcontent=%3Cp%3EVolunteer+and+be+part+of+the+World%26rsquo%3Bs+Largest+Music+Festival!+To+apply+to+become+a+xxx+STAR+Volunteer+please+complete%2C+sign+and+return+the+2012+xxx+New+Volunteer+Application.+Applications+should+be+mailed+to%3A+xxx+STAR+Volunteer%2C+200+N.+Harbor+Drive%2C+Milwaukee%2C+WI+53202+or+faxed+to%3A+414-287-4495%3C%2Fp%3E%0A%3Cp%3E%3Cbr+%2F%3E%3Ca+href%3D%22http%3A%2F%2Fwww.xxx.com%2FContent%2Fpdf%2F2012-volunteer-app.pdf%22%3EDownload+the+2012+Volunteer+Application%3C%2Fa%3E%3C%2Fp%3E&amp;_=1333636964810 500 (Internal Server Error) d.ajaxTransport.sendjquery-1.5.1.min.js:19 d.extend.ajaxjquery-1.5.1.min.js:19 (anonymous function)112:27 Ejquery-1.5.1.min.js:19 d.event.handlejquery-1.5.1.min.js:19 d.event.add.k.handle.m</pre> <pre class="prettyprint"><br /><br /></pre> <pre class="prettyprint">The code. I have this in the live site.</pre> <pre class="prettyprint">public class AllowCrossSiteJsonAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*"); base.OnActionExecuting(filterContext); } } [AllowCrossSiteJson] [ValidateInput(false)] public ActionResult Preview(int? id, FormCollection collection, ContentPageEdit obj, string htmlContent) { obj.ContentBody = htmlContent; return new JsonpResult { Data = new { content = obj.ContentBody }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; //return Json(obj, JsonRequestBehavior.AllowGet); }</pre> <pre class="prettyprint">I have this code being executed in an admin section:</pre> <pre class="prettyprint">&#36;('#preview').live('click', function (e) { // Code... var theContentBody = &#36;('#ContentBody').val(); try{ &#36;.getJSON("http://ws-devweb1.dmz.sf/preview/htmlContent=" + theContentBody, function (data) { alert(data.content); }); } catch(e){alert(e);} });</pre> <pre class="prettyprint"><br /><br /><br /></pre> <pre class="prettyprint">XMLHttpRequest cannot load http://xxx.com/preview/htmlContent=%3Cp%3EVolunteer%20and%20be%20part%20of%20the%20World&amp;rsquo;s%20Largest%20Music%20Festival!%20To%20apply%20to%20become%20a%xxx%20STAR%20Volunteer%20please%20complete,%20sign%20and%20return%20the%202012%xxx%20New%20Volunteer%20Application.%20Applications%20should%20be%20mailed%20to:%xxx%20STAR%20Volunteer,%20200%20N.%20Harbor%20Drive,%20Milwaukee,%20WI%2053202%20or%20faxed%20to:%20414-287-4495%3C/p%3E%3Cp%3E%3Cbr%20/%3E%3Ca%20href=%22http://www.xxx.com/Content/pdf/2012-volunteer-app.pdf%22%3EDownload%20the%202012%20Volunteer%20Application%3C/a%3E%3C/p%3E. Origin http://localhost:40304 is not allowed by Access-Control-Allow-Origin.</pre> <p></p> <p>I am following this link:&nbsp;<a href="http://stackoverflow.com/questions/7547672/ajax-json-post-to-controller-across-domains-not-allowed-by-access-control-all">http://stackoverflow.com/questions/7547672/ajax-json-post-to-controller-across-domains-not-allowed-by-access-control-all</a></p> 2012-04-05T14:18:08-04:004918835http://forums.asp.net/p/1789329/4918835.aspx/1?Re+getJSON+cross+domain+request+500+errorRe: .getJSON cross domain request 500 error <p>you are trying to use native cors with json. you must use a browser that supports this. if you use firefox, see the jquery ajax notes for a fix. chrome and safari shoudl work fine. you will need IE 10 or greater to use IE. &nbsp;&nbsp;</p> 2012-04-06T03:20:47-04:004919847http://forums.asp.net/p/1789329/4919847.aspx/1?Re+getJSON+cross+domain+request+500+errorRe: .getJSON cross domain request 500 error <p>This looks promising!&nbsp;<a href="http://www.west-wind.com/weblog/posts/2012/Apr/02/Creating-a-JSONP-Formatter-for-ASPNET-Web-API">http://www.west-wind.com/weblog/posts/2012/Apr/02/Creating-a-JSONP-Formatter-for-ASPNET-Web-API</a></p> <p></p> 2012-04-06T15:12:03-04:004920507http://forums.asp.net/p/1789329/4920507.aspx/1?Re+getJSON+cross+domain+request+500+errorRe: .getJSON cross domain request 500 error <p>Hi,</p> <p>You may check this-</p> <p><a href="http://forums.asp.net/p/1782901/4899363.aspx/1?Re&#43;problem&#43;in&#43;return&#43;result&#43;Ajax">http://forums.asp.net/p/1782901/4899363.aspx/1?Re&#43;problem&#43;in&#43;return&#43;result&#43;Ajax</a></p> 2012-04-07T07:26:17-04:00