We have an application that is installed on some 600 odd servers. This application exposes a web api which gets me version information of the application.
My requirement is to display the version of application on each of the server. I have achieved this in asp.net application by:
Writing a web method in aspx.cs page with server name as parameter. This method will build web api URL, invoke web api, get response, build a object and return as json string.
I have written an jquery ajax post request for each server name to the above method. On success, built a html table row and append it to table. so that as and when we get response it is shown to user.
This works absolutely fine for say 30-40 servers. But when it increases, it takes lot of time to process all requests (30 - 40 mins). And with multiple users using this asp.net app, we start getting error.
Is there a any other method to achieve this faster and for multiple users without errors?
How often is this information changed? If this data is rarely updated, I suggest the following.
Make every of servers to save this information into a shared database table when the server starts. If the application version can be changed while the server is operating, update a corresponding record in a database.
When your service gets information about the application version, get it once from the database table instead of requesting it directly from every server.
Related
I have developed a Windows Service that runs every 10 seconds and collects real time data from a couple of web services. That data is then collated and sent in an xml file to a web site outside my system.
I now have a requirement to display this real-time data in an internal web page, which can be viewed by user in our company.
One option would be to write this data to a database table and access it from the web page. However as the data is real time statistics, there is no requirement to store the data in the long term.
Is there a good way to pass the data to the web page so that it can be displayed to the users that does not require multiple calls to the database and put a strain on the network?
Any thoughts or ideas would be welcome.
I have a website, which was infected 4 years ago (!) by virus, which created many threads and fake users in ASP.NET Community like : /forum/members/Better-Flower-Delivery-Your-Flower-Delivery-c-uj.aspx .
This site is redesigned 2 years ago, ASP.NET Community is removed at all, but right now there are many requests are being went to my web-site (300 such fake requests per 2 hours)!
Of course requestor (robot) gets HTTP 404, but sends and sends such requests. Any ability to block these requests at all? Why do I want to do it?
I use Azure. So, I pay about each incoming data / CPU time to processing request.
these requests add litter to statistic, so, I should check what is it.
You can try to do something like this:
OnBeginRequest event, send to user a fake page with only one html form that contains some special generated number or string for this user inside hidden field and after page is loaded automatically send this form back to your server by js.
On your server, check this generated number, and if it's valid for this user, generate cookie that informs your system, that this is true user and has a browser.
So if user has your generated cookie with your generated pass, you are allow your server to process this request, if not, reject it.
This method allows you to control which request should be processed by your system, 'cause usually robots don't process responses.
Best regards, Dima.
Is it possible to get notification in my ASP.net Website from database if a table was been modified?
Example: if there is new message that come to my account. It will notify me on my website. I've tried to use ajax on this kind of feature but I want a better solution on this. AJAX is keep on requesting/communicating on the server even there is not new update on my table that why I find it not that good.
Please Help me on this problem.
What technology I should use? or please give me some related article.
Thanks!
No, it is not possible to get notification to your ASP.NET Website without an ajax request which keeps on communicating to a server in a given time interval. You can use SQL triggers to get information that your table has been updated or row has been added/deleted but to get that information too you'll need to make a request to your database server. I haven't came across any architecture in which database server automatically communicates to your web application/website until and unless a request is made by web application/website.
I have an ASP.NET website and a seperate C# application. The application writes data to a file, the website populates the treeview with the data in the file. I populate the treeview in the page Load event.
The website checks if the file has changed. This happens from a code behind file. If the file did change, the website needs to be refreshed. I cannot use Response.Redirect because I get a
Response is not available in this context
I tried System.Web.HttpContext.Current.Response.Redirect, but this gives me a NullReference.
How can I refresh the page from a code behind file, so that it loads the right data in the treeview? Other suggestions that work but use something else than refreshing the page are welcome. Thanks in advance!
Edit: The actual problem is dynamically updating the treeview (new data = updated treeview). I have tried to do something with data from a MySql database but failed. The idea is the same, except the data isn't coming from a file but from a database. I added this because I thought this info might help users understand my problem.
you can't send data to the client from an initiative of the server.
You will have to poll (jQuery/ajax) if new data is available, then refresh from the client side.
this involves basically :
on the server
a web service, webmethod page method, custom handler, etc. that can tell if new data is available
on the client
a timer that query the server if data is refreshed, and, in this case, that refresh the page, or reconstruct the DOM if using some JS templating
[Edit] a bit of background :
Actually, System.Web.HttpContext.Current.Response is null because of the asynchronous model of the Http protocol. The browser emits a request "http://srv/resource", the server intercept it on the port 80 (by default), parse the request, build a response (mostlya bunch of html content) and send the response the browser. Then the connection is closed. This choice allows a great scalability, as it does not requires to keeps thousands of connections alive with nearly no data passing on it.
The impact of this, is that the web server have to knowledge of the client, other than what is send in the request. The server receive text, and send text in return.
Microsoft has created the ASP.Net framework to reproduce the RAD feeling of desktop applications. You think with controls and events, not in producing html flow like ASP or PHP. They succeeded in the sense, that, building web apps are quite similar to desktop development.
The quite is actually what is causing you some confusion. Even if the asp.net framework encapsulate most of the plumbing (viewstate is the key) to simulate this behavior, asp.net will, at least, still be a parser for request text that produces a html text to send to the client, in one shot.
So you have to cheat. You can, as I suggested, automate the browser (using javascript) to wrap this asynchronous work into a "dynamic" application.
You can't successfully use a FileSystemWatcher from within a webpage.
The instance of the page lives just long enough to handle a single request. And after that request has been served, you can't issue a redirect. The browser will not be listening anymore.
You need to do polling from your webpage, using the date you last read that file. If the Last Modified date of that file has changed from what you remember, you will need to refresh your page.
A little background... I have a .NET webpage that communicates one way with a service. (using OnCustomCommand()) When the user presses a button, a function is called. Which is all good and dandy, however when the function is done executing I need to be able to send a message, function call, or some communication to the .NET webpage.
Is there a way for my service to call a function, send message or update my .Net webpage?
I've looked around and seen mostly .NET -> Service but nothing seems to go the other way.
EDIT: Its a windows service, and the ASP page and WindowsService reside on the same server.
Have the service write the output to a common area... such as a shared file, or a database. Then refresh the webpage and have it query that file for the response output.
Support more than one user you should have have some session ID that will be used to determine where the output is saved. For example, call a command line parameter with a GUID like this:
Echo This is a test > c:\Some Directory\Session12345.txt
And then have your aspx page query and refresh using a GET like this http://example.com/GetOutput.aspx?Session=12345
From there use ASP to access a file with an appended SessionID in the URL.
You can extend this concept to work with JQuery and WCF as needed. Of course, you will need to add security to this to prevent MITM attacks. But it sounds like this is a small project not connected to the internet so the extra features may not be that important.
Communication can only be done from client to server. Use Ajax/webservice/scriptmethod for retrieving status of service call.