javascript - Web API Parameter Path Too Long -


i'm making call web api method:

var url = rootwebapiurl + '/api/services/files/' + $scope.selectedserver.name + "/" + encodeuricomponent(fullpath) + '/';  $http.get(url) // rest of $http.get here... 

because fullpath variable long, path long error on physicalpath property in framework method have:

if (system.web.httpcontext.current != null && system.web.httpcontext.current.request.physicalpath.length > 0)     return applicationconfigurationweb; 

so thought perhaps pass data, can't seem call hit right web api method:

var req = {     method: 'get',     url: rootwebapiurl + '/api/services/files',     params: { servername: $scope.selectedserver.name, path: fullpath } }  $http(req)  // rest of here... 

is appropriate alternative larger data web api method? if so, how should url constructed right method? if not, how can past path long issue?

this web api method signature:

[route("api/services/files/{servername}/{path}")] [httpget] public ienumerable<filedll> files(string servername, string path) 

with updated call, 'params' should end being query string, if updated webapi route this:

[route("api/services/files")] 

and added attribute httpruntime node in system.web section of web.config

<httpruntime maxquerystringlength="32768" /> 

i believe should start working

edit

as davidg mentioned, more appropriate way post data instead of using get. so, you'd change request config this:

var req = {     method: 'post',     url: rootwebapiurl + '/api/services/files',     data: { servername: $scope.selectedserver.name, path: fullpath } } 

then update route so:

[route("api/services/files")] [httppost] public ienumerable<filedll> files(filedata mydata) 

where filedata class looks this:

public class filedata {     public string servername { get; set; }     public string path { get; set; } } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -