Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi frnds can any one please advice me a solution to my problem,...

i'm working on mvc3 razor apps,

i have myaccount details page which consists of different blocks of details like,

Name: under this block, first name, last name
address: address 1,2,city state, zip,...
license: number,expiry,issue country..

so whenever i edit any block i don't want page to getting refresh,so using jquery, ajax and json methods but, my problem is

C#
[JsonException]
      public JsonResult AccountDetailsUpdate(MyDetailsModel mydetailsmodel)
      {
        return View("viewname");
      }
but it throws me error, unable to convert JsonResult to ViewResult
i want to return to a view from json method, how can we make it
Posted
Updated 1-Feb-12 3:40am
v2

1 solution

You're returning a view. That is not a JsonResult. The error is telling you to return Json, because you said you would. This[^] shows how to return Json, the short version is

return Json(xxx)

where xxx can be a list, I usually end up returning an anonymous class like return Json(new { MyResult = true, MyValue = myVar } );, etc.
 
Share this answer
 
Comments
m19anand 2-Feb-12 2:49am    
Hi Christian Graus,

thanks for ur response, but actually my problem is that only, from this json method i should navigate to a particular view so I mentioned "Return View()" instead of Json(), cant i redirect a json method to a View...??? please say the solution to navigate to a view from this json method

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900