Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have developed and deployed few ASP.NET applications. Sometimes I want to stop the users from either inserting or updating a record when:

  1. Maintenance is going on.
  2. Stop operations due to payment delay.

In one of my recent application I have implemented this feature to first check the database operations for locked status. If any of the above condition fulfils, database operations like insert and update are not carried out.

I now need this feature in all the old applications and the future applications I build. I want to know whether WCF is suitable in this scenario as I want to share methods or an independent locking application among various other applications.

Is WCF appropriate for this type of scenario?

share|improve this question
1  
I would think the avalability of your service, however it is implemented would be you primary concern. WCF would be a workable choice, I've recently been considering servicestack.net but there ar many others en.wikipedia.org/wiki/List_of_web_service_frameworks. I think the reliability of your hosting should be your primary concern, do you want you applications to fail because your ISP is doing maintenance? –  Jodrell Jun 22 '12 at 16:12
add comment

3 Answers 3

up vote 8 down vote accepted
+50

I should begin by saying that WCF is the goto solution. What you mentioned above fits very well in the SOA (Service Oriented Architecture) definition, and WCF deals very well with SOA.

Implementing a single locking service application, which can then be then integrated in all your components would be ideal because:

  1. When you update your locking and payment checking methods, you do it one place only. So it gives you maintainability.
  2. You implement the code only once, which gives you reusability.
  3. In the central app you can always add new services, with new logic which can be coupled or decoupled of your existing model, from existing services. So you have scalability.
  4. It also gives you coolness, for all the reasons I mentioned above.

If anything else, then please ask.

share|improve this answer
1  
I agree and if the ASP.Net applications and WCF services are on one machine use the namedpipe binding otherwise use net.tcp binding. This is especially good for case 2 which is a business requirement and rules can change in futire. For case 1 arguably you can do a DB level check as that is more of a technical issue. –  Pratik Jun 17 '12 at 22:38
1  
This is the answer, and it is yes. WCF is the appropriate way to share information across multiple applications these days. –  deltree Jun 22 '12 at 19:54
add comment

You could insert a file on your webserver and protect it by placing it in a safe folder and make it only editable by admin user. In that file you could specify a string to indicate the system status. Accessing this file can be performed in any way you like. The reason for choosing a file is to be able to access it even if the database is down. This is a a very simple solution that serves the objective you described.

Eidt: Also, instead of a separate file, you could use a configuration item to server the same purpose.

share|improve this answer
1  
And how do you know that all the ASP.Net applications are deployed on one machine. This is a poor solution that doesn't take into account distributed and load-balanced deployment. Also it is poor from security perspective as well. The 'safe folder' should have write permission by all the ASP.Net apps that may have different application pool identity. Not very good. –  Pratik Jun 17 '12 at 22:35
    
@Pratik , I am aware that this solution has limitation. The OP did not mention that he/she is using multiple servers. The folder does not have to have write permissions at all. An application needs to read the file not write to it. The solution is very safe if correctly implemented. –  Emmad Kareem Jun 18 '12 at 4:08
    
Even if it is a single server, why not keep a separate SQL Server database instead of a file. –  RPK Jun 19 '12 at 18:02
    
@RPK, Using a file in this case is more generic because, you may want to shut down the site when you are doing database maintenance operation that you want to do off-line or if your database is built from batch feeds that are run on off-hours basis. If that is not the case, by all means, use a database table. –  Emmad Kareem Jun 19 '12 at 19:37
add comment

If you wanted a locking solution, a web service is not necessarily the way to go - the overhead involved is very great. So just to check "can I do some writes now" will require a lot of calls, and a webservice call is very slow (relatively speaking).

A more optimised solution would be to keep with your database calls, but to move the sql to a stored procedure that can also check the locked status as part of the query. Alternatively, keep the lock check as local as possible, checking whether a file exists is quick (as the OS tends to cache such files if they're accessed often) and easy, especially if you're reading your applications' code from files or writing to logs anyway.

share|improve this answer
2  
I would say this is a hack, not a real solution. A real solution has to work on a long term, not just now, when it's needed. –  marceln Jun 17 '12 at 21:23
    
what, stored procedures are a hack?! Sure the file isn't perfect, but it a common practice in scripted language web serving. Putting a trivial web service call in every page request is simply not a scalable solution. –  gbjbaanb Jun 18 '12 at 9:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.