jsonresult

Get the Current ViewContext in ASP.Net MVC

I have a ASP.Net MVC JsonResult function in which I want to return the contents of a PartialView (The content has to be loaded using Ajax, and for some reason I can't return a PartialViewResult). To render the PartialView I need the ViewContext object. How do you get the current ViewContext object within an Action method? I don't even ...

Loading & saving 'trimmed' serialized object via JsonResult by jQuery $.getJson

I am trying to use asp.net MVC controllers JsonResult to CRUD db records. e.g. GET /Config/Folder/1 - will return a json serialized LinqToSql entity POST /Config/Folder - will send form data back to the server to be deserialized and persisted back to the database. I am using james newton-kings JSON.net to serialize the entity, althou...

Can I convert a JSON string into JsonResult ?

I have some stored JSON strings stored in the DB which I want to return to the client as JsonResult . I know that Json(object) turns an object into JsonResult but what if I already have the result in a string ? can I cast it to JsonResult ...

Return Multiple Objects Using ASP.NET MVC'S JsonResult Class....

Is it possible to Multiple Objects Using ASP.NET MVC'S JsonResult Class.... Here is a controller method which returns json object of my records but i also want to pass the count value.... var materials = consRepository.FindAllMaterials().AsQueryable(); var count = materials.Count(); var results = new PagedList<MaterialsObj>(materials, c...

Is this valid data for jquery ajax call to aspnet mvc controller?

I am using jquery with asp.net mvc.... Is my data option valid or am i missing some thing... $.ajax({ type:"POST", url: "Materials/GetRecords", data: "{'currentPage':1,'pageSize':5}", Any suggestion.... EDIT: I am calling a function from a view page, <asp:Content ID="Content2" ContentPlaceHolderI...

Django and json request

In a template i have the following code <script> var url="/mypjt/my_timer" $.post(url, paramarr, function callbackHandler(dict) { alert('got response back'); if (dict.flag == 2) { alert('1'); $.jGrowl("Data could not be ...

How to either return JSON or RedirectToAction?

I have an Action Method that I'd either like to return JSON from on one condition or redirect on another condition. I thought that I could do this by returning ActionResult from my method but doing this causes the error "not all code paths return a value" Can anyone tell me what I'm doing wrong? Or how to achieve the desired result? He...

How to redirect to a controller action from a JSONResult method in ASP.NET MVC?

I am fetching records for a user based on his UserId as a JsonResult... public JsonResult GetClients(int currentPage, int pageSize) { if (Session["UserId"] != "") { var clients = clirep.FindAllClients().AsQueryable(); var count = clients.Count(); var results = new PagedList<ClientBO>(clients, currentPage - 1, pag...

json returned from a jsonresult in asp.net mvc .....

I am returning this from a json result from a controller, var genericResult = new { redirectUrl = Url.Action("Create", "Registration") , isRedirect = true }; return Json(genericResult); but when i inspect through firebug, {"redirectUrl":"/","isRedirect":true} if (data.isRedirect) { ...

How can I use a RESTful JSONResult from my controller to populate Bing Maps Geocoding?

I know there are a few topics on this, but I seem to be fumbling my way through with no results. I'm trying to use a controller to return JSON results to my Bing Maps functions. Here's what I have for my controller (yes it is properly returning JSON data. Function Regions() As JsonResult Dim rj As New List(Of RtnJson)() rj.Add...

After HttpPost, returning a View (ActionResult) when Model is not valid, the response has content type of application/json

I'm running into a strange issue in more than one page of my ASP.NET MVC site. When I POST a form and the Model is NOT valid, I try to return the same view so that I can see the errors - however, instead of the page getting reloaded, I get a pop-up download box that says that the file is in "application/json" format. As you can see fro...

ASP.NET MVC - Pass Json String to View using ViewData

I'm trying to pass Json to my View using ViewData Controller ViewData("JsonRegionList") = Json(RegionService.GetActiveRegions()) view $("input#UserRegion").autocomplete({ source:"<%: ViewData("JsonRegionList").ToString %>", minLength: 3, but the problem I'm running into is the output source ...

Json returns different dates when local machine and server in different timezones

I have a strange problem in json date parsing. I am using the following to parse the json date: dateFormat(new Date(parseInt(user.RegDate.substr(6))), "mm/dd/yyyy") When my local machine (Client) is in different timezone from the server timezone, then it returns different dates when i try to retrieve the registered date of the users. ...

Call action of another controller and return its result to View

I have a scenario where I need the following functionality: In View I have call as: $.ajax({ type: "POST", async: false, dataType: 'json', url: "ControllerA/ActionA", data: { var1: some_value }, success: function (data) { if (data == true) { form.submit(); } else if (data == fa...

mvc 2 jsonresult output

hello, how can i see the raw json output of mvc 2 jsonresult? i need this to enable me debug the results. thanks ...

ASP.Net MVC: how to create a JsonResult based on raw Json Data

Having a string containing the following raw Json data (simplified for the sake of the question): var MyString = "{ 'val': 'apple' }"; How can I create a JsonResult object representing MyString? I tried to use the Json(object) method. but it handles the raw json data as an string -logically :P-. So the returned HTTP response looks...