views:

49

answers:

1

Hi,

I have a webservice to give access to some resources on a network. The service has a method to look for the resource and returns the path of the resource. Another method, send to request to the webservice with this path. I try to pass the entire UNC path (encoded with HttpServerUtlility.UrlTokenEncode method) to the webservice. The resulting URI is very long (331 characters) and I get "HTTP 400 Bad Request". How do I handle such long URIs ? If my URI is shorter by some 10 characters, then the request goes through. Unfortunately, the size of URI is variable and can be more in some case. What changes do I need to make? Are there any setting in config file to allow for long URIs?

Thanks

+1  A: 

Enumerate the resources you want to give access to and store a dictionary/sql table to them indexed by guid.

ex:

3941dbffc1b54581837010a42b42635d = //server/path/to/file

the first method would return the guid, and the second would look up the guid to find the file

Bill Barry
Note that you don't have to create the mapping ahead of time. Whenever a resource is requested for the first time, create a mapping for it, and then utilize that mapping from then on. If clients are going to cache the guid, make sure to store it in some persistent state so it can be retrieved when your server is rebooted, etc.
eeeeaaii
Is there any other way? I do not want to lookup for a given guid each time.
Debby
I suppose that if there is only a couple of directories where the resources are located, you could use an int for the directory lookup and the filename.Or if you can be certain that the files are uniquely named, you could simply use the filename.If the length of the guid is too much for you you can easily use something like ShortGuid: http://blog.muonlab.com/2010/03/24/shortening-guids-in-mvc-uris/
Bill Barry