c# - The resource could not be found HttpGet -
i trying data website, trying localhost first. request fails. changing post works fine.
error: resource cannot found.
controller action:
[httpget()] public actionresult getinformation(string id) { uri uri = new uri("http://localhost:65076/showdetails?id=" + id); httpwebrequest request = (system.net.httpwebrequest)system.net.webrequest.create(uri); request.method = webrequestmethods.http.get; httpwebresponse response = (system.net.httpwebresponse)request.getresponse(); streamreader reader = new streamreader(response.getresponsestream()); string tmp = reader.readtoend(); response.close(); return json(new { data = tmp }); }
javascript function:
function getinformation() { var link = '/home/getinformation'; var id = '11111'; $.ajax({ type: 'get', url: link, data: { id: id }, datatype: 'json', success: function (result) { $.each(result.data, function (item, value) { ... }); }, error: function (result) { ... } }); };
since get, pass in data in querystring:
function getinformation() { var link = '/home/getinformation?id=11111'; $.ajax({ type: 'get', url: link, datatype: 'json', success: function (result) { $.each(result.data, function (item, value) { ... }); }, error: function (result) { ... } }); };
Comments
Post a Comment