Hello world!
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
//upload
[HttpPost,Route(“upload”)]
public async System.Threading.Tasks.Task<HttpResponseMessage> test()
{
var httpRequest = HttpContext.Current.Request;
foreach (string file in httpRequest.Files)
{
var postedFile = httpRequest.Files[file];
var originalFileExtension = Path.GetExtension(postedFile.FileName);//dosya uzantısını verir
var filePath = HttpContext.Current.Server.MapPath(“~/” + postedFile.FileName);
postedFile.SaveAs(filePath);
}
return Request.CreateResponse(HttpStatusCode.OK, “yüklendi”);
}
//asenkron
[HttpGet]
[Route(“harf/{harf}”)]
public async Task<ApiResponse<List<Firmalar>>> harfeGore(string harf)
{
var result = new ApiResponse<List<Firmalar>>();
await Task.Run(() =>
result.Data = db.Firmalar.Where(x => x.firmaAdi.StartsWith(harf)).OrderBy(x=>x.firmaAdi).ToList());
return result.Success();
}
//attribute
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // veri yoksa jsonda dönmez
// verileri json formatında döndürür (global.asax içine)
GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
// web api filter
public class MyFilter : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
string[] sonuc =(string[]) actionContext.Request.Headers.GetValues(“Sitekey”);
if (sonuc[0] == “girme”)//response doldurulursa işleme girmez
actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.OK, “BURDA GİRMEDİ”);
// OnActionExecuted()
}
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
}
}
Hi, this is a comment.
To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.