There is an open source windows form client for Xibo that contains embedded web browsers. The problem is that while one web browser is getting busy, the other browsers and controls in the form can't respond and they actually pause. So I thought maybe it is a good idea to have one thread for each web browser with it's own application message loop. But it seems unsafe to add controllers created in different threads to a single form. In fact I was lucky to have some browsers in different threads by a few lines of code refactor before I realized it actually should not work at all!
Is it a good way to make it possible? What is the best solution to make such an application multithreaded with minimum coding?
I know that similar thing is asked for WPF application but I want to know is there anyway to find out the application idle time for an MVC application so that I can show the session timeout popup like banking websites.
I currently searched on websites and I found this link:
http://community.devexpress.com/blogs/aspnet/archive/2011/06/15/asp-net-how-to-show-a-popup-warning-before-session-timeout.aspx
But if anyone could share better solution, it would be nice.
They typically just start a javascript timer, then after it times out, they just redirect to the logout page. It's actually quite simple, but it has nothing to do with the actual apps idle timeout.
You can add a nifty gui to it, but it's not particularly difficult.
I have a WPF browser application that collects user data and adds it to a database to tell them when their software is out of date.
All of that works fine, but the problem is when the application finishes its stuff, I want the web page itself to change (i.e., detect the web app has hit a 'finished' state, then autonagivate to a results page or something).
I can't think of a way to accomplish this, since the web app itself doesn't seem to be able to change the IFRAME it's contained in, much less the page outside of that, or signal to javascript or anything.
Any ideas?
I'd make an variable to keep progress/step of work. And a timer which would check if progress=="done" or sth.
Maybe this is not the best way of solving this but I don't know WPF much and that solution first came to mind
I've read tons of other questions and googled the issue, but I can only figure out how to do it if I'm using winforms. I'm currently writing a library, and one of the functions of the library is to handle logging. One of the features I'm implementing for it is to automatically take a screenshot of the page before writing the issue to the log. The issue with this is that I don't know which monitor to take a screenshot of, so if the user moves the browser to a different monitor, I still take a shot of the Primary one.
public static Bitmap ScreenShot(string saveLocation, string fileName)
{
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics.FromImage(bitmap).CopyFromScreen(0, 0, 0, 0, bitmap.Size);
string savePath = Path.Combine(Path.GetDirectoryName(saveLocation), "ScreenShots");
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
bitmap.Save(Path.Combine(savePath, fileName), ImageFormat.Png);
return bitmap;
}
I've tried Screen.FromControl(), but since it's not a winforms application, I don't have any System.Windows.Forms.Controls for it to find.
Does ASP.NET have any equivalent? Or something I can explicitly cast to a winform control?
This just won't work. Your c# code is running on the web server, not on the user's web browser and not on their computer. The only monitors that code will have access to are the monitor attached to your web server.
This probably appears to work on your development platform, but only because there your web server and your client machine are the same machine.
The best you can hope for is to include a flash or silverlight object on the page that can take the capture, and even that probably won't work.
Surely any code you're running here will be running on the server so will have no idea where its being displayed
In theory you could use JS to capture the DOM and then send it back to the service via an Ajax call - that's the closest you'll get I would think
You're trying to take a screenshot of the client's screen from an ASP.NET application? That isn't possible. You may be able to log the entire request including the HTML then re-render it somewhere else, but you can't have that kind of interaction with the client from a server-side application framework.
if the user moves the browser to a different monitor, I still take a shot of the Primary one
ASP.NET runs on the server, so writing server code to screen capture the browser is meaningless. You may have better luck using client-side code (javascript) to take a screenshot.
This thread uses an ActiveX solution:
Take a screenshot of a webpage with JavaScript?
ASP.Net WebForms do not work as you might be thinking they do. The short answer is no, you cannot do this in ASP.Net. There is no equivalent.
WinForms are displayed by interacting with the Windows operating system and are shown on the same computer's desktop. WebForms are displayed by generating HTML and sending the HTML to another computer's browser. Your ASP.Net code is not running on the other computer's browser. If your code is attempting to take a screen shot, then at-best, you will get the server's (or your computer's) display.
You can run code on the browser using JavaScript - but you still shouldn't be taking screen shots (and I don't think JavaScript will let you - at least not automatically). For one, you will be including other information from their screen which may not be related.
When ASP.Net encounters a problem, it will log the details in the Windows log on the server and also (with less detail) in the IIS log files. Consider emailing yourself an alert when an error is encountered and looking in the logs to see what went wrong.
I would steal the algorithm currently used by google+. I definitely do not have the exact algorithm, or even one that is close to the actual thing, but I think this is what it's doing:
user clicks on 'log/report error'
server renders the current page using the position of the scroll bar and the size of the window (accessible through JS).
server renders a div covering the entire window and places the image inside of it. This div has the highest z-index.
when the user clicks on the div, a new div is generated that allows the user to "highlight" selected areas. The user is then allowed to attach a comment to this selected area.
It's genius in execution.
The only possiblity I can think of is something client-side that asks the browser to take a screenshot and then upload it. FogBugz does something like this with its new-case tool but that's an add-in your users would have to download and install.
I did this for a bug tracking app a long time ago using an ActiveX control written in --gasp-- Visual Basic. Something like that (other than the cool Google+ trick mentioned) is about your only choice.
One of the sites I maintain relies heavily on the use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error.
This appears to only happen in Safari. Firefox, IE and Opera all load successfully in the same scenario.
While I second the Channel 9 solution, also be aware that in some hosted environments Safari is not considered an up-level browser. You may need to add it to your application's browscap in order to make use of some ASP.Net features.
That was the root cause of some headaches we had for a client's site that used the ASP Menu control.
My first port of call would be to go through the elements on the page and see which controls:
Will still work when I switch ViewState off
Can be moved out of the page and into an AJAX call to be loaded when required
Failing that, and here's the disclaimer - I've never used this solution on a web-facing site - but in the past where I've wanted to eliminate massive ViewStates in limited-audience applications I have stored the ViewState in the Session.
It has worked for me because the hit to memory isn't significant for the number of users, but if you're running a fairly popular site I wouldn't recommend this approach. However, if the Session solution works for Safari you could always detect the user agent and fudge appropriately.
I've been doing a little research into this and whilst I'm not entirely sure its the cause I believe it is because Safari is not returning the full result set (hence cropping it).
I have been in dicussion with another developer and found the following post on Channel 9 as well which recommends making use of the SQL State service to store the viewstate avoiding the postback issue and also page size.
http://channel9.msdn.com/forums/TechOff/250549-ASPNET-ViewState-flawed-architecture/?CommentID=270477#263702
Does this seem like the best solution?