Blocking specific images in windows - c#

I am doing some web scraping for a research project and have some bandwidth limitations that I am hitting. Due to the nature of my work, I require this to be done through a web browser control(geckofx for csharp). Because of this, I cannot control images that get loaded.
My question is, in windows, is there any way to force certain images to not load. I know web pages can be blocked via hosts file, but it does not work on specific images on a page.
Ideally such a tool would have regex/wildcard for specifying blocked image sets.

You can use Fiddler (or Fiddler Core) as proxy and you should be able to do pretty much anything with each request. In your case you may want to issue additional HEAD request in the script for image requests and see if size is acceptable, if not fail the original request...

Related

Detect user device with blazor server

Is there a way to detect the device the user is using with blazor server on .net 7? or at least know what resolution they're using so i can check if it's portrait of landscape mode
The only way the server can directly know anything about the client machine or browser is if that information is sent. Do not depend on this happening.
If you really want to get real dimensions, there are many ways to do this in Javascript. So you want to look up Javascript Interop in Blazor.
But if you need to know the dimensions of the screen, except in very special cases, you're probably doing things wrongly. CSS rules include media queries, generally based on width. CSS also includes unit measurements like vh and vw, which represent a proportion of the width or height of the screen.
As a web developer, you will learn that fighting against the protocol of the day is likely to end up with you in tears-- because you make a solution that works on your own phone, and then someone with an Apple device, or an older device, or an uncommon browser, tries to use your site. Then you discover that your "production" site is garbage.

Build whole web application not per page

I created a website on MVC C# and locally it behaves as it is expected, but once I upload it on Azure it starts loading slow (initial load), each page takes its own time. I've enabled the Always On feature, but it didn't do much good. Now the question is if there is a way to force on access the whole web application to be build instead of the Page by page mode that is currently active.
If you mean the initial request takes long and then any subsequent requests are fast, then that would be because you are hitting .NET apps cold start. Many .NET apps are slow to JIT and load all their .NET requirements, but once everything is loaded, they are fast.
As scheien said, please choose the closest region when choose app service plan.
If pages still loading slow. I would suggest you use Windows Internet Explorer Developer Tools Network Capture to find out detailed issue: https://msdn.microsoft.com/en-us/library/gg130952(v=vs.85).aspx. If it related with your application, please optimize the code.
Regards

running an application inside ASP.NET

I've written an application in C# that I would now like to host within an ASP.NET website (MVC 2).
The application can become quite resource intensive so I would like to set up the system in such a way that each user downloads the application and runs it locally, but still within the web page that I provide.
My first idea to solve this problem was to host the program within a silverlight application. However, the app I want to host was not compiled for Silverlight, and I would like to use MySQL in it, which also appears to not be possible directly (ie without a web service in between).
The bottom line is that don't have experience with these things directly yet, and I need to research the way to make any solution possible. So I would really appreciate some input to put me in the right direction, and not have to implement 3 wrong options before finding the right one. I would also really like to avoid JavaScript if at all possible.
Thanks in advance.
Update
I probably should have specified to begin with what the application is exactly.
The application as I want to host it on the website is a simple chat program. It needs an input box and text output. The old windows forms application won't have to run in ASP, but I want to use the class library behind it, which is a chatbot engine. That engine is the part that can be rather resource intensive.
So you wrote a "rich client" application and you want to serve it as a web/silverlight application. This is not possible without changing the architecture of your app, as you probably guess, expecially because you have to interface a database. If rewriting the application to support such architecture is not an option, the best in order to me is to use Remote Desktop, but you have to pay for licenses in order to support many connections.
If your application is not a web application then it will not run on the server. The only thing your server does is to provide a download location. For that, you wouldn't need a MVC site - static pages could fit. The programming model between normal applications running on the client and server applications running on IIS is completely different. So in short: you won't be able to host your client application in ASP.NET MVC. If this is a requirement you will end up rewriting the application.
If your application is ASP.NET WebForms and it becomes too resource hungry, then you probably won't solve it by just switching to MVC. You have different options then: more resources on the server side, analyzing what could be done to lower the resources required or moving away from a server based application. This is not a black/white decision, maybe a combination might fit.

Request for Advice c# Webplayer

I am currently building an asp.net c# Website for a client of mine to promote their band, on there they would like to have a Webplayer which continues to play music as people are browsing the site. The player is located on the Master page so it is included on every site, but it stops playing every time the site does a postback or refreshes in any way.
I think it is possible to achive this using Iframes or Ajax, although i dont have alot of knowledge in either.The site is only about 6 pages with mainly static information on there, so the only postbacks/refreshes will be done by using the navigation menu to load each page.
My question to you is:
how can I achive this?
what would be the easiest method and what are the pros and cons?
are there any other/better ways of achiving this other than using Iframes or Ajax?
I can provide some code if needed.
Thanks,
Seb
The easiest way to achieve this would probably be to have your site put itself into a frame, where another (very small) frame on the page hosts the media player. That way when people switch pages, the frame with the media player is left alone. However, this will probably come out feeling pretty clunky at best.
The best way is probably to use AJAX. All of your page navigation would happen as AJAX requests, so the user never technically leaves the original page. An iframe will probably be necessary for tracking history so the user can click "back" and have the browser do what they expect, but you can find libraries that will take care of that aspect for you. The media player should probably use a different subdomain for its source than the rest of the site content, because most browsers max out at two simultaneous connections to the same domain--your site could feel sluggish if one of these two connections is being used for the music stream at all times.

Is it possible to have javascript communication between 2 WebBrowsers in winform

I have a winform with 2 WebBrowser control. Is there a way for one page to communicate with the other directly?
For example in HTML and frames, one page can access window.parent.frames[1].document for example.
Not directly, because those will be two separate browser instances. You can however write some communication layer of your own. Obviously you'll have to tailor the websites you are showing for this as well.
Technically it is feasible like the web chat between two or more people in Gmail or Facebook.
This is not a simple task, but today there is the HTML5's websockets or if you target older browsers as well, you could poll the server on both frames and share some statuses that you read every few seconds.
In any case, this is a messaging(string) communication (eg: a stringified JSON) that you can pass.But you will never be able to access the DOM of the other browser/frame.

Categories