/
DbHandler.ashx.cs
54 lines (46 loc) · 1.43 KB
/
DbHandler.ashx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
namespace Html5_Storage
{
/// <summary>
/// Summary description for DbHandler
/// </summary>
public class DbHandler : IHttpHandler
{
/// <summary>
/// Json Çıktısı Olarak AppData İçindeki İlleri Servisten Yayınlıyoruz
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";
Dictionary<int,string> iller = new Dictionary<int, string>();
using (StreamReader stramreader = new StreamReader(context.Server.MapPath("App_Data\\veri.txt")))
{
while (stramreader.Peek()>=0)
{
try
{
string[] satir = stramreader.ReadLine().ToString().Split(' ');
iller.Add(int.Parse(satir[0].Trim()), satir[1]);
}
catch (Exception)
{
}
}
}
context.Response.Write(JsonConvert.SerializeObject(iller.ToList()));
}
public bool IsReusable
{
get
{
return false;
}
}
}
}