Hello to everyone!
I am working on project that is client program( WinForm ). When i create new form for new functionality, i need to make a lot of requests to API. For instance i need get statuses to show on form, get data for grid view, check some users data, and so on!
So, question is: Is it ok to have more than 1 request to API, when i load form?
If not how to decrease number of request? or may be i need new method to API, that will return all that data? Thanks!
It is not a best solution that u can make more request to api in form load. You try to write override methods to api if it is open source. so that you can reduce more calls. Learn the api completely about its functionality. If you need more precise answer please post the code or samples which might help you to get what exactly you want.
Related
So Im still trying to find the feature (if it is there) in Cefsharp 3, where one can inspect the headers from the response of a request. In case its not there, is it because it is not there in CEF 3 ? and or, where should i start looking, if Im to implement it ?
This feature is not in CEF 3 yet. Here's the outstanding issue for it:
https://code.google.com/p/chromiumembedded/issues/detail?id=515
There is a workaround noted...
There's no great way to filter response contents with CEF3 currently. You can use CefResourceHandler via CefRequestHandler::GetResourceHandler and execute the request/return the response contents yourself using CefURLRequest.
... however this workaround is not possible in CefSharp 3 because CefURLRequestClient and friends are not implemented.
At this stage, depending on how comfortable you are with C++ you might consider:
contributing to the (C++) CEF project and implement the response filtering feature - this will be all C++.
contributing C# wrappers of CefURLRequestClient and friends to the CefSharp project - which is a combination of light C++ and C#.
You might also be interested that there is a way to get HTTP headers in JavaScript, as long as you have initiated the request yourself using AJAX:
Accessing the web page's HTTP Headers in JavaScript
This type of solution could easily be done with CefSharp 3 by injecting JavaScript into the current page.
An alternative that provides more control is to use schemehandlers (it's cleaner IMO).
Add a scheme handler that intercepts your resource loading:
CEF.RegisterScheme("ascheme", new HandlerFactory());
then (once you've created a trivial factory or 2) you have this override available:
public bool ProcessRequestAsync(IRequest request, ISchemeHandlerResponse response, OnRequestCompletedHandler requestCompletedCallback)
The Response contains Headers/MimeType and Stream to allow more control. I hope this helps.
I am using the JQuery UI Modal Form Dialog and trying to save the old data and new data to a database. I am using C# (backend) and ASP.NET front end. I can delete new entries, I just don't know how to save the data. I have tried searching ways to pull pull the HTML data in, but couldn't get rid of the errors. Also Wasn't sure if there was a better method? Here is my JSFiddle
function addUser() {
I need to figure out a way to get the data from the table and post it to the server.
I think what you may be looking for is web methods, it allows the jquery (client side) to call the backend (c#) and for them to interact with each other.
Check out this link for reference:
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/
Here is a brief summary from the website:
When it comes to lightweight client-side communication, I’ve noticed
that many of you prefer ASP.NET AJAX’s page methods to full ASMX web
services. In fact, page methods came up in the very first comment on
my article about using jQuery to consume ASMX web services. Given
their popularity, I’d like to give them their due attention. As a
result of Justin‘s question in those comments, I discovered that you
can call page methods via jQuery. In fact, it turns out that you can
even do it without involving the ScriptManager at all. In this post, I
will clarify exactly what is and isn’t necessary in order to use page
methods. Then, I’ll show you how to use jQuery to call a page method
without using the ScriptManager.
I found this:
This script gets data from the table that you can then parse through.
You could then pass it into a hidden field.
I'm trying if it is possible to get the result of another site after clicking some items and altering some data on that site.
For example, you have a site which asks you first for some input and then gives a result. This result i want to have and save it to a database and display it on my own site. Is there any possibility for this?
I searched for hours and i can only find static examples.
Any help or link would be much appriciated.
It's possible. Use fiddler to detect what the form post (assuming its a form post) looks like. You can then recreate the post using an HttpWebRequest and swap your unique values in.
We are downloading a full web page using System.Net.WebClient class. But we only want less than half of the page. So is there a way to download a portion of the page, say 1/3rd, half etc of a page using .net library so that We can save the network bandwidth and the space? If so, please throw your ideas, thanks.
You need to provide an "Accept-Ranges header" to your GET or POST request. That can be done by using the AddRange method of your HttpWebRequest:
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create("http://www.foo.com");
myHttpWebRequest.AddRange(0,100);
That would yield the first 100 bytes. The server, however, needs to support this.
The sort answer is not unless the web app supports some way to tailor it's response to what you want it to return.
This could take the form of a
query string parameter
header field value
The simplest way to add this would be a query string parameter and when detected write out the necessary HTML to the response object. If you are unable to make changes to the web app then you won't be able to control how much of a page is returned to you.
You might want to read up on how HTTP works since the question and it's answer relies upon this. Specifically the Header Definition should be helpful.
response = service.getInfo(request);
How can I display an image while my response object is being populated? Service is a web service located on another server that I have no control over.
Any help is greatly appreciated.
Here is one way to do it.
The bottom line is that you will need some asynchronous process going on. And that implies AJAX. The library or methodology you use is up to you.