Wednesday, December 31, 2014

Alert for Bootstrap

Do this if you want a Bootstrap alert at the top of your page.  Swap out 'alert-warning' for 'alert-error' if you want red instead of yellow.
 @if(Model.Message != null){  
      <div class="alert alert-warning">  
           <button type="button" class="close" data-dismiss="alert">&times;</button>  
           @Model.Message  
      </div>  
 }  

Delete a Remote Git Branch

To delete a branch from the server, do the following:
git push origin --delete serverfix

Saturday, December 27, 2014

File changes aren't ignored even when in the .gitignore file

If Git insists on checking in changes to a file even when the .gitignore file seems like it should be excluded, it is probably because the file is already in the repository.  Git will not ignore a file if it has already been committed.

To resolve this, open a Bash prompt in the root folder of the repository.   ( A shortcut for this in SourceTree is to click on the 'Actions/Open in Terminal' menu.   Run the following:
git rm --cached FolderName/MyFileName.ext
Then commit the change and push it up, and it should ignore the file from then on (assuming your .gitignore was correct to begin with).   Note that this will leave the file as is in your source folder.

Tuesday, December 9, 2014

Call via HTTPClient to an SSL endpoint without a valid certificate

This isn't always a good idea, but sometimes you have to call an http endpoint using that has an SSL certificate that is not valid.  To allow the connection and disregard the certificate error, you can do something like the following:

 using (var client = new HttpClient(new HttpClientHandler()));  
 {  
   // this is the line that will ignore the certificate issues.  
   ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };  
   var response = taskClient.GetAsync(uri).Result;  
 }