logo
down
shadow

ApiController vs ODataController when exposing DTOs


ApiController vs ODataController when exposing DTOs

Content Index :

ApiController vs ODataController when exposing DTOs
Tag : .net , By : bashmish
Date : December 01 2020, 04:55 PM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

In RESTful Web Services, should Response DTOs contain their child DTOs?


Tag : json , By : Jack
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , To be RESTful you don't necessarily have to return the full representation of the resource You do however want to enable hypermedia as means to get/set all the information the user of your API needs (Hypermedia as the engine of application state - a.k.a. HATEOAS)
To satisfy that you can either use the suggestion by @bowmanb to put a URI for all the locations or add individual URIs for each of the locations. You probably want to add additional URIs for other options of doing something with the resource.

Web API 2.2 - ApiController to ODataController (changing Content Type after setting Formatter)


Tag : development , By : user152423
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Actually I got it working the way I wanted, more or less, by using OWIN and writing my own middleware.
Basically I wanted a way to force a content-type without having to write a specific oData formatter for each instance. So oData could continue to format whichever way it was told to, and I would just tell the browser to treat it as plain text (or whatever else I wanted it to be).
public class OWINCustomMiddleware : OwinMiddleware {

  public OWINCustomMiddleware(OwinMiddleware next): base(next) {
  }

  public async override Task Invoke(IOwinContext context) {

  //Check if a content-type coercion querystring token is present
    if (context.Request.QueryString.HasValue) {
      NameValueCollection queryString = HttpUtility.ParseQueryString(context.Request.QueryString.Value);
      String coerce = queryString.Get("$coerce");
      if (!String.IsNullOrWhiteSpace(coerce)) {
      //Remove $coerce token so it doesn't impact future methods
        queryString.Remove("$coerce");
        context.Request.QueryString = new QueryString(queryString.ToString());
      //Append a header to the request, to be later used in Response Content-Type coercion
        context.Request.Headers.Add("coerce", new String[] { coerce });
      }
    }

    await Next.Invoke(context);

  //Coerce existing response content-type to value of coerce header (if present)
    if (context.Request.Headers != null) {
      if (context.Request.Headers["coerce"] != null) {
        Int32 index = context.Response.ContentType.IndexOf(';');
        if (index > 0) {
          context.Response.ContentType = context.Request.Headers["coerce"] + context.Response.ContentType.Substring(index, context.Response.ContentType.Length - index);
        } else {
          context.Response.ContentType = context.Request.Headers["coerce"];
        }
      }
    }

  }
}

Should input DTOs for RESTful endpoints match the output DTOs?


Tag : rest , By : James Cary
Date : March 29 2020, 07:55 AM
This might help you It seems the REST consensus is that when updating using PUT, one supplies the entire entity to replace.
Programmatically, it would work having PUT /person/{id} accepting input which behind the scenes maps to UpdatePersonDTO instead of Person.

odata query works again ApiController but does not work again ODataController


Tag : asp.net-web-api , By : Mr. Tacos
Date : March 29 2020, 07:55 AM
With these it helps First, from the namespace System.Web.OData.ODataController, I think you are using the Web API OData V4 library. V4 doesn't accept application/atomsvc+xml because only "Json" is the standard in OData V4 spec.
Second, odata=fullmetadata is the OData V3 metadata header, for V4, it should be odata.metadata=full

WebApi (ApiController) vs OData (ODataController) in ASP.Net MVC


Tag : asp.net-mvc , By : platformNomad
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Tabs for a ASP.NET website
  • AccountManagement.UserPrincipal.Current takes 5 seconds
  • Will linq to sql work in an asp.net 2.0 web application?
  • .Net Regular Expression to get parenthetical text at end of <p> tags
  • The Project Location is Not Trusted error in Visual Studio
  • how to tell if a photo was taken in landscape or portrait? JPEG .NET metadata orientation
  • Winform and ValidateChildren()
  • Why need to mention "Supported by the .NET Compact Framework" for classes members?
  • Pass MSI parameters to .NET installer class
  • How to print stack trace of StackOverflowException
  • OnPropertyChange as an Alternative to Triggers in Entity Framework
  • "User Friendly" .net compatible Regex/Text matching tools?
  • Non-Ascii characters not supported by .net?
  • Linq SqlMethods.Like fails
  • To check whether the SQL server DB is working properly or not
  • What is the Difference between GC.GetTotalMemory(false) and GC.GetTotalMemory(true)
  • Which version of .NET is available for Xbox 360?
  • Validation (with custom ErrorTemplate) for a DataTemplate
  • is the threadpool shared - .net
  • WPF RichTextBox - Formatting of typed text
  • "ResizeEnd" equivalent for usercontrols
  • How work with common utils project
  • Using image resource in XAML markup?
  • How to use XML namespace prefixes without xmlns="..." everywhere? (.NET)
  • How to write an altered COM Structured Storage file to Disk?
  • Implementing auditing using Autofac if it support method interception?
  • How can a static class be resolved by the Unity Framework?
  • How to flush DNS cache in Windows Mobile programmatically?
  • how to set autoplay=true in google audio player?
  • Edit dialog, with bindings and OK/Cancel in WPF
  • What does MailMessage.IsBodyHtml do?
  • C# Class Library wont register for COM
  • Robust DateTime parser library for .NET
  • MySql BulkCopy/Insert from DataReader
  • How do I allow all users access to one route within a website with integrated auth?
  • Reading from a oracle temp table in a separate procedure than the one it was populted in
  • Recommendations for IPC between parent and child processes in .NET?
  • F# 1.9.9.9 and lapack
  • How to get a majority color in an image?
  • Rename parameter in a WCF client interface
  • In WPF: Children.Remove or Children.Clear doesn't free objects
  • Convincing Management to use WCF
  • How to access a property in a class used to implement IDispatchMessageInspector on a WCF service (server side)?
  • How to generate distinct random numbers per distinct threads in .NET?
  • Cannot read app.config, why?
  • Using a DataSet instead of custom business entities in soa and n-tier architecture
  • .NET assembly loading problem
  • Code Trivia: optimize the code for multiple nested loops
  • .NET compilation without JIT possible?
  • Is it safe to use ThreadStatic variable in WCF?
  • Managed and unmanaged code in .NET
  • Back button in ajax update panel not working
  • Problem using ‘useLegacyV2RuntimeActivationPolicy’ & supportedRuntime in an application
  • I've built a Windows service as "Any CPU". Why does it run in 32-bit mode on my 64 bit machine?
  • Is there any way to disable the "double-click to copy" functionality of a .NET label?
  • Verify installation of ASP.NET Ajax Extension
  • Allow IExtenderProvider control to attach to controls on a UserControl
  • Hooking into AppInitialize with WCF service
  • Outlook 2003 add-in - Getting COM exception on application shutdown after creating WPF window
  • WCF 4.0 new enhancements over WCF 3.5
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com