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?

4

1 回答 1

7

还是有更好的方法?

是的,在您的设置控制器操作中检查数据库是否已经创建,如果它不运行代码,只需返回一些错误或其他什么。

基本上,只有当您可以通过编程方式确定该代码正在做什么尚未完成时,该代码才会运行。

于 2013-07-31T12:05:30.703 回答