1

I'm currently using asp.net web api for the first time and having problems with 404s being returned when trying to post to a particular method.

The api works fine but when one of the parameters reaches a certain length a 404 is returned.

The parameter in question is only around 2000 characters in length.

This is the signature for the api method:

public Boolean Add(String Source, Int32 CreatedByID, String CreatedBy, 
            String Header, String Body, Boolean IsLive, Boolean IsNotification)

Any ideas what I'm doing wrong? I'm calling my api with angular if that makes any difference.

StuartLC
  • 104,537
  • 17
  • 209
  • 285
David
  • 209
  • 4
  • 17
  • 1
    If doing a post, then why not use Add([FormData] YourObject yourObject) and serialize he post data to that object, instead of passing query string params. Sounds like you are not really using an httppost – Tim Mar 28 '14 at 11:51
  • Hi Tim, I'm using the $http service in angular and specifying POST as the method. Its strange as it works fine but as soon as one of the parameters gets to a certain length it returns 404. – David Mar 28 '14 at 11:58

2 Answers2

1

The max length for a url is 2000 characters in some browsers so try with less parameters and see if it helps.

1

A GREAT explanation and CREDIT goes here: What is the maximum length of a URL in different browsers?

Some key points in case the other ever gets lost... I have kept the extracts verbatim" so as not to pretend this is my own work!

Short answer - de facto limit of 2000 characters

If you keep URLs under 2000 characters, they'll work in virtually any combination of client and server software.

Longer answer - first, the standards...

RFC 2616 (Hypertext Transfer Protocol HTTP/1.1) section 3.2.1 says

The HTTP protocol does not place any a priori limit on the length of
a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.

Internet Explorer's limitations...

IE8's maximum URL length is 2083 chars, and it seems IE9 has a similar limit.

I've tested IE10 and the address bar will only accept 2083 chars. You can click a URL which is longer than this, but the address bar will still only show 2083 characters of this link.

Community
  • 1
  • 1
Belogix
  • 8,129
  • 1
  • 27
  • 32