For a project I’m currently working on I needed a dynamic robots.txt. Because our test environment is public facing we want to keep it from being indexed by Google etc. It took a bit of Googling to find a solution that worked, but in the end it was actually pretty simple.
Also need to add the following to your web.config so that the robots.txt file can processed by the routing handler. Without this IIS will attempt to serve it as a static file and will return a 404 when it’s not found:
<system.webServer><modules><!-- ... --><handlers><addname="RobotsTxt"path="robots.txt"verb="GET"type="System.Web.Handlers.TransferRequestHandler"preCondition="integratedMode,runtimeVersionv4.0"/><!-- Other handlers --></modules><!-- ... --></system.webServer>
I hit the following error when trying to execute a composed request with Fiddler:
[Fiddler] The connection to ‘abc.com’ failed. System.Security.SecurityException Failed to negotiate HTTPS connection with server.fiddler.network.https> HTTPS handshake to abc.com (for #32) failed. System.Security.Authentication.AuthenticationException A call to SSPI failed, see inner exception. < The function requested is not supported
All that was required to fix it was to add tls 1.2:
I ran into the following error after adding model validation attributes to a database with existing values:
String or binary data would be truncated.
The statement has been terminated.
The solution is pretty straightforward if you’re happy to truncate the values. Simply run the query below, swapping Title for your column name, Products for your table name and 25 for your new column length:
SET Title =LEFT(Title,25)WHERE LEN(Title)>25
You should then be able to run update-database without any issues:
Specify the ‘-Verbose’ flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201806240741543_product_validation].
Applying explicit migration: 201806240741543_product_validation.
Running Seed method.