Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP Windows NET
In my project I use http api which returns xml responce. The problem is that the http addresses have significant number of parameters and are too long. Thats whay I get this error:
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
 
I tried in webconfig file to write:
<httpRuntime maxUrlLength="1000" relaxedUrlToFileSystemMapping="true"/>
 
Didn't work..
I tryed putting the long string into a uri but then visual studio tells about an error and wants a string.
Here's my code
string encoded = Server.UrlEncode("https://test.httpapi.com/api/domains/register.xml?auth-userid=0&auth-password=password&domain-name=domain.asia&years=1&ns=ns1.domain.com&ns=ns2.domain.com&customer-id=0&reg-contact-id=0&admin-contact-id=0&tech-contact-id=0&billing-contact-id=0&invoice-option=KeepInvoice&protect-privacy=true");
try
{
    XmlDocument doc = new XmlDocument();
    doc.Load(encoded);
    ....other code to get the loaded xml data....
}
 
I need a way to work around this limitation for < 260 characters. The string I posted is only a demo, my string is even longer after I add all the variables. I did a lot of search for this problem and got nothing, even tryed the "\\?\" witch is a work around but not for a http path. Please help..
Posted 15-Feb-12 3:21am
kms_310
Edited 15-Feb-12 3:46am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
You can use a tinyurl service to shorten the URL.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
You can use a tinyurl service to shorten the URL.
  Permalink  
Comments
Michael dg at 15-Feb-12 10:40am
   
how about using POST instead of GET method?
kms_ at 16-Feb-12 2:26am
   
sorry.. you have to be more specific.. can you give me an example..
but I decided to give the tinyURL a shot, seeing that I have no other alternative
kms_ at 16-Feb-12 3:50am
   
Thank you very much "Michael dg".. it's a little risky doing it with a tinyurl, but the good new is that it worked.. Lets hope the service is up and running 24/7 :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

You can use Long Path Tool for such problems, it works good.
  Permalink  
Comments
CHill60 at 25-Jan-14 12:46pm
   
Question is nearly 2 years old and already has an accepted answer. It is also usual to give a link to the tool in your solution. Reviewers of that tool claim that only the paid version works
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

As you already know it can't be longer than 248/260 characters and your url is 292 characters and therefor to long. That's windows... limited by licence...
 
More info on XmlDocument.Load here: http://msdn.microsoft.com/en-us/library/875kz807.aspx[^]
 
Good luck!
  Permalink  

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

  Print Answers RSS
0 CHill60 280
1 Sarvesh Kumar Gupta 238
2 Sergey Alexandrovich Kryukov 203
3 OriginalGriff 163
4 DamithSL 153


Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 25 Jan 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid