Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6535321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:21:35+00:00 2026-05-25T10:21:35+00:00

Can you do the below in WCF 4.0 Rest like you can in ASP.NET

  • 0

Can you do the below in WCF 4.0 Rest like you can in ASP.NET MVC?

In ASP.NET MVC I can create a strongly typed object commonly known as a ViewModel to handle error validation.

Instead of the following:

public ActionResult SomeAction(string firstname, string lastname, string address, int phone)

I could have the following:

public ActionResult SomeAction(UserObject obj)

Where UserObject is defined as:

public class UserObject
{
   [Required(ErrorMessage = "firstname is a required paramater")]
   public string firstname { get; set; }
   [StringLength(50, ErrorMessage = "lastname is too long")]
   public string lastname { get; set; }
   [StringLength(160)]
   public string address { get; set; }
   public int phone { get; set; }
}

What I am basically wanting to do is create the parameters in a strongly typed object and have my error messages there. I could then format the error message as xml and return it to the user.

So in WCF REST. Instead of My method looking like:

[WebGet]
public IEnumerable<ObjectResult> SomeAction(string firstname, string lastname, string address, int phone)

I want the following:

[WebGet]
public IEnumerable<ObjectResult> SomeAction(UserObject obj)

Is this possible in WCF REST 4.0?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:21:35+00:00Added an answer on May 25, 2026 at 10:21 am

    Default WCF is not able to do that. You must create custom behavior with custom implementation of IDispatchMessageFormatter to collect parameters from query string and build the object. Here is an example how to build such behavior and formatter. It would be like if you have to write custom model binder for each custom ViewModel in ASP.NET MVC.

    Btw. there is also no build in logic which would simply allow you to call validation (like Model.IsValid in MVC). You will need to use infrastructure classes used with data annotations manually (System.ComponentModel.DataAnnotations.Validator).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In android the Toggle buttons are looks like below - Can we modify this
I am trying to create a logging service using WCF Rest. It looks something
I was using a method like below on the previous versions of WCF Web
Can some one tell me how to post request to a wcf rest service?
I am making a webservice (can't shift to wcf due to .net req). My
As you can see below, I have Parallel.For loop. If run the program while
From the disassembly code below can I assume that the location 43E010 is a
The simple code block below can be served up in a static HTML page
I'm using graphviz (dot) to generate the graph you can see below. The node
I have two async classes in my application which you can see below class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.