web api
Enable PUT and DELETE in IIS
Context
- IIS with WebDav
- WebDav is not required
Problem
Original Web.config:
<modules >
<remove name="FormsAuthentication" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</modules >
Related errors:
- HTTP Error 405.0 - Method Not Allowed from WebDAVModule
Solution
Web.config:
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
<remove name="FormsAuthentication" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</modules >
IIS:
- select site
- webdav authorizing rules
- disable webdav
How to Rollback a Database Migration From a Remote SQL Server
The scope of this solution is to explain how to recover from a desynchronization between your project database version and your remote server database. How to correctly rollback in both development and remote servers is out of scope.
Scenario:
- You apply the last migration last_migration.cs both at the development and remote (test or production) server
- You rollback the last migration from your development server by issuing: update-database -targetMigration previous_to_the_last_migration.cs
- You remove the file last_migration.cs from your development server. Mistake!
- You want to apply the rollback to the remote server and you publish your project. You get an error!
- You cannot simply remove the entire database and regenerate it again because it contains plenty of data. You need a solution!
Solution 1:
If you had open ports to connect to remotely to the SQL Server, then you simply do: update-database -targetMigration previous_to_the_last_migration.cs -ConnectionString "YOURCONNECTIONSTRING".
Solution 2:
Given that you do have access to the remote server by e.g. a RDP connection, we'll make use of SQL Server Management Studio (SSMS):
- Log in SSMS,
- Open the database
- Edit table __MigrationHistory
- Delete the line with MigrationId "last_migration"
- Revert the changes applied by last_migration.cs manually at the corresponding database tables
- Publish the project again
- Done