[RESOLVED]How to pass object of class in url action in mvc C#

How to pass object of class with value in url action in mvc C#

Generally, you aren’t going to be able to pass complex objects via the URL (or in this case a URL action) as objects would have to be able to be serialized as a QueryString (which the Url.Action helper helps accomplish).

You can consider passing each of the individual properties for your object using something like this :

@Url.Action("Action","Controller", new { PropertyA = Model.PropertyA, PropertyB = Model.PropertyB, ... })

and then MVC would map each of those properties to a particular Model for your Action using something like :

public ActionResult Action(Model model)
      // If your Model class had the appropriate properties you passed in within your View, they will be populated here

Aside from that, the most common approaches to persist an entire object would be to use something like the TempData or Session (for temporary storage), or if you were using an object that was stored within a database, simply pass across the ID values and
retrieve the object using the ID within your Controller Action.

Hi  vraju9896,

Thanks for your post.


How to pass object of class with value in url action in mvc C#

You can convert the model into an JSON object by using the the build-in JSON-helper,like this:


Hope this can be helpful.

Best Regards,



Leave a Reply