Skip to content

Instantly share code, notes, and snippets.

@kdhollow
kdhollow / web.config_with_error_passthrough
Last active February 2, 2022 10:03
web.config addition to allow error passthrough
<system.webServer>
...
<httpErrors errorMode="Detailed" existingResponse="PassThrough">
</httpErrors>
...
</system.webServer>
@kdhollow
kdhollow / gist:88c4372297a02a7f1eb5
Created February 24, 2016 07:12
app.config containing Azure Search parameters
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SearchServiceName" value="<YOUR SEARCH SERVICE NAME HERE>" />
<add key="SearchServiceApiKey" value="<YOUR KEY HERE>" />
<add key="SearchServiceIndexName" value="airports" />
<add key="SearchServiceSuggesterName" value="suggester" />
</appSettings>
</configuration>
@kdhollow
kdhollow / gist:6866ab9aae1046da49eb
Created February 24, 2016 07:13
CSV Containing AFD Information for Airports
0A3,SMITHVILLE,TN,SMITHVILLE MUNI,ATLANTA,SE,http://aeronav.faa.gov/afd/04feb2016/se_386_04FEB2016.pdf
0A4,JOHNSON CITY,TN,JOHNSON CITY,CINCINNATI,SE,http://aeronav.faa.gov/afd/04feb2016/se_369_04FEB2016.pdf
0A9,ELIZABETHTON,TN,ELIZABETHTON MUNI,CINCINNATI,SE,http://aeronav.faa.gov/afd/04feb2016/se_362_04FEB2016.pdf
0M2,TIPTONVILLE,TN,REELFOOT LAKE,ST LOUIS,SE,http://aeronav.faa.gov/afd/04feb2016/se_390_04FEB2016.pdf
0M3,HOHENWALD,TN,JOHN A BAKER FLD,ATLANTA,SE,http://aeronav.faa.gov/afd/04feb2016/se_365_04FEB2016.pdf
0M4,CAMDEN,TN,BENTON CO,ST LOUIS,SE,http://aeronav.faa.gov/afd/04feb2016/se_355_04FEB2016.pdf
0M5,WAVERLY,TN,HUMPHREYS CO,ST LOUIS,SE,http://aeronav.faa.gov/afd/04feb2016/se_392_04FEB2016.pdf
1A0,CHATTANOOGA,TN,DALLAS BAY SKY PARK,ATLANTA,SE,http://aeronav.faa.gov/afd/04feb2016/se_356_04FEB2016.pdf
1A3,COPPERHILL,TN,MARTIN CAMPBELL FLD,ATLANTA,SE,http://aeronav.faa.gov/afd/04feb2016/se_359_04FEB2016.pdf
1A7,GAINESBORO,TN,JACKSON CO,ST LOUIS,SE,http://aeronav.faa.gov/afd/04feb2016/se_363_04FEB201
@kdhollow
kdhollow / gist:e0f40ffae85e64ffdb50
Created February 24, 2016 07:14
Azure Search Test Initialization Code
private AzureSearchEngine azureSearchEngine;
private string indexName;
private string suggesterName;
private System.IO.Stream csvFile;
[TestInitialize]
public void Initialize()
{
indexName = ConfigurationManager.AppSettings["SearchServiceIndexName"];
suggesterName = ConfigurationManager.AppSettings["SearchServiceSuggesterName"];
@kdhollow
kdhollow / gist:4ad9997cba1d5e37a052
Created February 24, 2016 07:15
Azure Search Data Parse and Index Code
var airportIndexTasks = Parse( async (identifier, city, state, name, chart, region, afdlink) =>
{
var airport = new Airport()
{
Id = Guid.NewGuid().ToString("N"),
Identifier = identifier,
City = city,
State = state,
Name = name,
Chart = chart,
@kdhollow
kdhollow / gist:29f1ac6df78e2ac4ec3f
Created February 24, 2016 07:16
Azure Search Supporting Functions
private delegate Task AirportInfoDelegate(string identifier, string city, string state, string name, string chart, string region, string afdlink);
private IEnumerable<Task> Parse(AirportInfoDelegate airportInfoCallback)
{
var parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(this.csvFile);
parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited;
parser.SetDelimiters(",");
while (!parser.EndOfData)
{
//Process row
string[] fields = parser.ReadFields();
@kdhollow
kdhollow / gist:700af8e5dd69c8368ac6
Created February 24, 2016 07:18
Azure Search Example Airport Class
namespace AFDSearch.Models
{
public class Airport
{
public string Id { get; set; }
public string Identifier { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Name { get; set; }
public string Chart { get; set; }
@kdhollow
kdhollow / gist:48ba96fda279bfdcd6c3
Created February 25, 2016 19:25
Views\Home\Index.cshtml
@using AFDSearch.Models
@model AirportSearch
@{
ViewBag.Title = "Airport Search";
}
@using (Html.BeginForm("Search", "Airport", FormMethod.Post))
{
@Html.TextBoxFor(m => m.SearchText)
@kdhollow
kdhollow / gist:59130c993e5ad2276bbc
Created February 25, 2016 19:27
Views\Shared\_Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
@using AFDSearch.Models
@model AirportSearch
@{
ViewBag.Title = "Airport Search";
}
@using (Html.BeginForm("Search", "Airport", FormMethod.Post))
{
@Html.TextBoxFor(m => m.SearchText)