WebBrowser control do not download images - c#

I am automating the process of downloading my bank statement. The way I do this is by using a win forms WebBrowser control. I navigate to https://www.bankofamerica.com/ then I find the username and password textboxes in the dom fill them in with c# send click event to the submit button etc etc. Eventually I get to the statement I want to download when ready I just parse the page source.
The process works but it is very slow. In summary I will like to improve the performance of this process These are the things I am considering:
Use fiddler to see the requests and responses hoping I could automate the same process. (The problem with this approach is that the connection is encrypted also I have to set cookies and I belive it will be to complicated to do it this way).
Prevent WebBrowser Control from downloading images and css. That way the page.Ready event will fire earlier and the process could be faster.
I will rader go with option number 2 because I know very little about fiddler and just know the basics of http. How can I speed up this process?

It's trivial to capture encrypted traffic with Fiddler; simply enable the Decrypt HTTPS connections option.
It's also easy to disable download of images from the Web Browser control using the "Ambient DLControl" flags. See http://www.tech-archive.net/Archive/InetSDK/microsoft.public.inetsdk.programming.webbrowser_ctl/2009-01/msg00035.html for an example.

Related

How to open a webpage on a local computer outside of its hosted RDP connection?

I would like to know if there is a technique or solution for the follow problem.
I have a software application that is currently running inside of a Microsoft RDP session. I have some help resources built into it in which some of them open up on a webbrowser. Some of them are YouTube videos. The problem is taht through organisational policies, they cannot open YouTube clips within the RDP which connects to a interstate server.
What I would like to do is instead open up a webpage outside of that RDP connection on the local host computer instead, which does not have any restrictions like opening up YouTube webpage to play video clips.
Can you please suggest a technique, utility or solution to this problem?
Thanks,
Colin.
The nicest way to do this would probably be to create a dynamic virtual channel plugin for RDP: https://msdn.microsoft.com/en-us/library/bb540859(v=vs.85).aspx
You would have a server-side component registered to handle the protocols (http/https, I assume) you want to redirect back to the client, possibly with some filtering logic if you still want a few to run server-side (such as intranet sites); then a client-side mstsc plugin whose only job is to call ShellExecute on the URLs you pass back.
Piggybacking on clipboard redirection might be less code, but it obviously has side-effects - e.g it obliterates anything else the user might have had on the clipboard.

Delete uploaded image if user goes from the page

I develop web application functionality sending message with attached image to another user. User can see preview of the image and make some crop before sending.
So at first I upload the image to the server and than show this image for user for preview. But what if user just close browser or go to another page, then there will be unused image file on the server. How to handle it? Or maybe there is better approach that don't need to upload image to the server at all?
This is something that can be done using JavaScript's FileReader. You can edit the image on the client side without having to upload the image to the server. Then you can perform the upload only when the user opts to send the message. This article has an example of such functionality: http://www.aspsnippets.com/Articles/Crop-and-Upload-Image-with-Thumbnail-using-jQuery-and-HTML5-in-ASPNet.aspx
To provide a good user experience a website should give him a welcome back. So in your case you can use the AnonymousIdentification to keep track of your returned users even if the browser is crashed or the tab is closed.
You can keep the information related to that specific anonymous user and keep track of them with their activities including the Image uploading (in your case). Then if the doesn't come back for a specific time of period you can delete that uploaded image.
Or maybe there is better approach that don't need to upload image to the server at all?
Yes it can be achieved via HTML5 features for file handling and canvas feature.
See these links for details:
Html5_ImageUploader
Drag&Drop with Crop via Ajax
I have built this before with a timestamp, after the crop you remove the timestamp in the table.
Have a service that runs say every 15 minute and looks for unconfirmed images and then delete from the server. This obviously still gives the data transfer but works quite well. I don't know how to handle EACH client close (even browser crashes....)
this plugins http://fengyuanchen.github.io/cropper/
http://deepliquid.com/content/Jcrop.html will crop image without upload to server.

Chatting and file sharing using C# in Asp.Net Webforms

NET Web-forms based application in c#. I need to add a module in the application which allows chatting between logged in users and users can share files during chatting, like Skype. Meanwhile I have to keep a PERMANENT RECORD of each and every word of conversation and files transferred during the session, on my server. I have a bit idea about the implementation of module to achieve the desired result, but I am sure that is not a good practice. Here is my idea:
Chatting:
While users are chatting, create a data-table which will contain the sender id, receiver id, and message contents. When ever user presses send button or hit Enter, a new row would be inserted in the data-table with both IDs and message contents and then the data-table will be bound to a div etc. to show updated messages to both users. At the end, on an event (like window close etc) data-table will be converted to the XML and the XML file will be stored permanently either on hard disk or in database.
File-transfer:
During chatting whenever user press enter/send button we will check the message contents, if the message being sent is a file (with some extension) then upload the file on server and provide a download link to the receiver.
I hope you got my point.
Problem:
1) I want to share files asynchronously i.e. transfer to the receiver and save on the server at the same time. Is it possible?
2) How to tell one user that the other user is typing?
Is there any better way to implement this module? What sort of knowledge should I have to properly comprehend and implement the module?
Thanks for any guidance.
For web-based real-time chat the current open source standard bearer seems to be SignalR.
There are quite a few discussions here on SO about that product and those should help move you in the right direction.
As far as storage is concerned, that will depend upon the infrastructure you have available and the costs you are willing to incur to build the system.
You might look into using RabbitMQ for message delivery and if you set that up appropriately, you can attach queue listeners that will also perform logging of chats as needed. (There are well documented .NET/C# clients already available for RabbitMQ.) You may also want to check out the Wikipedia page for RabbitMQ.
File transfer would probably be best done through uploading of the file to the web-server and temporary storage there with a link to the file to be downloaded by the other chat client. That causes the server to increase its bandwidth requirements though.
You might also look into running your own XMPP server and using a web interface through SignalR to interface into the XMPP server. It might leverage the most functionality for easing time to market.
Have you looked into SignalR?

Postback via webservice

I work for a radio station and they want a now playing and coming next on their radio player.
I currently have xml that I will be saving to my live webserver via a webservice. Is there a way to only get the radio player to postback when the xml changes rather than every second via a timer control? We have had performance issues with frequent postbacks in the past so would like to avoid crashing our server. I am using c# asp.net 3.5.
Personally i would recommend doing this with ajax. You can then cache the response at the server side so you dont need to do any heavy lifting in the bulk of requests.
What you want to do is to have your ajax query the server every 10s or so to get the current and next song as a json response. Take the response and put it into your page.
In asp.net you could also possibly do this with an update panel but this would cause significantly more load on both the server and the client.
Comet solution or ETag may help

C# observer pattern message filtering

I'm writing a video cms and want all my users to have new assets displayed immediately as they come in.
If I'm right, facebook updates its wall-page in realtime. So when I post something to a friend it immediately displays on his wall. The realtime web, as they say.
I wonder how you do that? Not the technology of client-server-communication, but what goes on on the server.
I understand the principles of the observer-pattern.
But a wall is in fact a query on a table of messages.
How does the observer know what query a user is interested in?
Does it hold all the query's of all connected users and reruns it when something new comes in.
I believe Google-realtime works that way to.
Thank you for helping me out.
When you open facebook, open the script timeline in your browser to see what scripts are executing on the page. You'll notice that there is a polling script being executed several times a second. So the page is looking at the cache several times a second to see if there is any new information that can be displayed.
http://www.ajaxwith.com/Poll-vs-Push-Technology.html - this should give you a background on the subject.
Facebook uses AJAX and a JavaScript timer that polls in the background looking for anything that's changed. Other sites use the same type of functionality to update stock quotes embedded in the page, etc. It's not truly updating immediately, it's updating as frequently as the JavaScript timer hits their server. This is because web browsers use HTTP, which is a request/response protocol. A browser won't display anything that's not as a direct response to a request initiated by the browser; there's no way to just send content directly to the browser from your webserver.

Categories

Resources