Here’s how you can setup a 410 Status Code using C#. Just place this code in the code-behind file in the Page_Load event handler, replacing www.domain_name.com with your domain name, of course:
Response.StatusCode = 410;
if (Request.ServerVariables["SERVER_NAME"].ToString().ToLower() == "www.domain_name.com");
Sorry I haven’t had time to blog in over a year. I’ve been busy working on a MongoDB project. I just came across this issue with a customer the other day and couldn’t find the answer to this question:
How do I find and delete the ASP.NET temp folder contents for a specific site while leaving the other temporary files for other sites alone?
Sometimes, ASP.NET will return an error with the specific path in the ASP.NET temp folder showing a conflict in two .dll files. In this case, it’s easy. Just delete the files. But what do you do when it just tells you there is a conflict in assemblies but doesn’t show the path? Here is the work around solution I came up with:
1) Rename the web.config file temporarily to something else like web.config.bak.
2) Reload the site to force a recompile.
3) Rename web.config.bak back to web.config.
4) Reload the site again to force a recompile.
This should clear out the ASP.NET temp folder contents for that specific site each time the site is recompiled.
As the title suggests, the following code converts a DateTime object to the “datetime-local” type used in HTML5 input controls (i.e. format 2016-10-30T00:00:00.00). I developed this while working on a personal application using C# and MongoDB. It uses the ToJson() function/method of the MongoDB Driver.
Datetime dt = new DateTime();
var dtLocal = dt.ToJson().ToString().Replace("ISODate(\"", "").Replace("Z\")", "");
Hopefully by posting this, it will help others save time.