1

I have a 'Setup' view and associated controller which I use to configure the database and web.config of an MVC site immediately after cloning the site from source control.

Once it's been run once, I want to prevent the code in my 'Setup' controller method from ever being run again.

Would programmatically deleting the 'Setup' view at the end of my 'Setup' controller method suffice, or is there a better approach?

2
  • 2
    Can't you detect on the controller if the task is done and just return a proper message or redirect? Commented Jul 31, 2013 at 12:05
  • 3
    Have you considered some guarding logic in the controller instead? Such operations (as the one you are suggesting) might be dangerous to the health of whole app. Commented Jul 31, 2013 at 12:06

1 Answer 1

7

or is there a better approach?

Yes, in your Setup controller action check if the database is already created and if it is don't run the code, simply return some error or whatever.

Basically the code will run only if whatever this code is doing is not yet done which you could determine programatically.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.