I have one asp.net mvc 3 application.
public ActionResult Students()
{
return View();
}
When i request these actions thru browser, everything works fine. It returns appropriate views, but when such actions are called from another site(across domain) thru jQuery Ajax call, It give transport error.
as a result we need to return such views in JsonpResult type, but now the problem is how do browser load such views of type JsonpResult ? it doesn’t return html part of the view instead it asks browser to save view result of type Jsonp.
Any suggestion, how to solve this ?
thanks.
You could use the
RenderPartialViewToStringmethod shown in this answer to render the view to a string and then return the custom JsonpResult you have written:The
JsonpResultclass used here could be found in this post.And now you could invoke this controller action using AJAX from another domain: