.NET Projende Gizli Paketleri Bulma: dotnet nuget why Kullanım Rehberi CI/CD pipeline’ında Trivy, Snyk veya benzeri bir güvenlik tarama aracı çalıştırdığında bazen karşına hiç tanımadığın bir paket ismi çıkar. Örneğin geçtiğimiz hafta bir taramada...
Kategori: C#
ASP.NET Core Web API Model Binding Öznitelikleri Nedir? [FromBody], [FromQuery], [FromRoute] Kapsamlı Rehber
Web API geliştiren herkesin bildiği gibi, bir istekte gönderilen verinin nereden geldiğini, hangi parametreye nasıl bağlandığını bilmek kritik öneme sahiptir. ASP.NET Core, bu süreci yönetmek için güçlü bir model binding mekanizması ve bunu yönlendiren...
Hardening an ASP.NET container running on Kubernetes
Dockerfile üzerinde yapacağınız bir kaç düzenleme ile container daha güvenli hale getirebilirsiniz. https://techcommunity.microsoft.com/t5/microsoft-developer-community/hardening-an-asp-net-container-running-on-kubernetes/ba-p/2542224 https://stackoverflow.com/questions/72821020/how-to-resolve-permission-denied-on-net6-in-eks
NInject Cheat Sheet
NInject Cheat Sheet https://lukewickstead.wordpress.com/2013/01/18/ninject-cheat-sheet/
Tlbimp.exe (Type Library Importer)
The Type Library Importer converts the type definitions found within a COM type library into equivalent definitions in a common language runtime assembly. The output of Tlbimp.exe is a binary file (an assembly) that...
web.config ‘e proxy eklemek
<system.net> <defaultProxy useDefaultCredentials=”true”> <proxy usesystemdefault=”True” proxyaddress=”http://127.X.X.X:8080″ bypassonlocal=”True” /> </defaultProxy> </system.net>
Is it possible to specify proxy credentials in your web.config?
namespace SomeNameSpace { public class MyProxy : IWebProxy { public ICredentials Credentials { get { return new NetworkCredential("user", "password"); } //or get { return new NetworkCredential("user", "password","domain"); } set { } } public Uri...
Tasarım Desenleri ve Mimarileri
https://github.com/Cerberuss?tab=repositories
(HttpWebRequest)WebRequest.Create(url);
try { WebProxy oWebProxy = new WebProxy(ConfigurationManager.AppSettings[“ProxyAddress”]) { Credentials = CredentialCache.DefaultCredentials }; string url = "htt://www.yakupkalebasi.com/"; var req = (HttpWebRequest)WebRequest.Create(url); req.Proxy = oWebProxy; req.Method = "GET"; var resp = req.GetResponse(); var outStream = resp.GetResponseStream();...
IBAN Kontrol
https://github.com/eozban/csharp/tree/master/IBANKontrol
IP Adres Bulma
public string IP() { string ip = "" if (HttpContext.Current.Request.ServerVariables[“HTTP_X_FORWARDED_FOR”] != null) { ip = HttpContext.Current.Request.ServerVariables[“HTTP_X_FORWARDED_FOR”]; if (!string.IsNullOrEmpty(ip)) { string[] ipRange = ip.Split(",".ToCharArray()); ip = ipRange[0]; } } if (string.IsNullOrEmpty(ip)) if (HttpContext.Current.Request.ServerVariables[“REMOTE_ADDR”] != null)...
String Format for DateTime
This site has great examples check it out // create date time 2008-03-09 16:05:07.123 DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123); String.Format("{0:y yy yyy yyyy}", dt); // "8 08 008 2008"...
ASP.NET 4.0’da ClientIDMode ile HTML ID’lerinin kontrolü.
ASP.NET'te en sevmediğim özelliklerden biri yaratılan HTML kodu üzerindeki kontrolün pek de mümkün olmaması. Aslında bu sevmediğim özellik ASP.NET'in işimizi bu kadar kolaylaştırabilmesini sağlayan en önemli altyapısı ile ilişkili. Fakat derdime çare arayacak olsam...
Windows Server 2012 / IIS 8.0 uygulamalarında tarih formatının “d.M.yyyy” olarak değişmiş olması
Merhaba Arkadaşlar, Varsayılan tarih formatı “Windows Server 2012” üzerinde, “Windows Server 2008 R2” den farklı olduğu için, IIS uygulamalarınızı IIS 8.0 üzerine taşırken, uygulamanızda kullanmakta olduğunuz tarih formatlarında değişiklik olduğunu farketmiş olabilirsiniz. Bunu en basitinden aşağıdaki “aspx” kodunu kullanarak test edebilirsiniz. Bu kod “System.DateTime.Now” çıktısını...
Online C# Compile
http://rextester.com/
How to change WSDL URL from internal machine name to public?
<serviceBehaviors> <behavior name="<name>"> <!– Other options would go here –> <useRequestHeadersForMetadataAddress> <defaultPorts> <!– Use your own port numbers –> <add scheme="http" port="81" /> <add scheme="https" port="444" /> </defaultPorts> </useRequestHeadersForMetadataAddress> </behavior> </serviceBehaviors> Kaynak: https://stackoverflow.com/questions/5007270/how-to-change-wsdl-url-from-internal-machine-name-to-public?answertab=votes#tab-top
C# Caller Information
namespace CallerInfo { public class CallerInfoExample { public void Log(String logMessage, [CallerMemberName] string callerName="", [CallerLineNumber] int lineNumber=0, [CallerFilePath] string filePath="") { Console.WriteLine("Çağrıldığı Dosya=" + filePath); Console.WriteLine("Çağıran Metod="+callerName); Console.WriteLine("Çağrıldığı Satır Numarası=" + lineNumber); } }...
Mapper kütüphaneleri Performans Testi
Aşağıdaki yazının sonuç kısmını paylaşmak istedim. 4 Farklı renklere ayrılma sebebi 1,10,100 ve 1000 kayıt üzerinde yapılan işlemler sonucunda hangi Mapper türünün ne kadar sürdüğünü ayırtedebilmek için. 4 farklı değerdeki parametre sonucunda mapper türlerinin...
SQL Server Data Types and Their .NET Framework Equivalents
SQL Server data type CLR data type (SQL Server) CLR data type (.NET Framework) varbinary SqlBytes, SqlBinary Byte[] binary SqlBytes, SqlBinary Byte[] varbinary(1), binary(1) SqlBytes, SqlBinary byte, Byte[] image None None ...
c# program info
string _AppName = "<unknown>"; var _MachineName = Environment.MachineName; if (Assembly.GetEntryAssembly() != null) { _AppName = Assembly.GetEntryAssembly().Location; } var _AppDomainFriendlyName = AppDomain.CurrentDomain.FriendlyName; var _UTCTime = DateTime.UtcNow; var _OSPlatform = Environment.OSVersion.Platform.ToString(); var _OSVersion = Environment.OSVersion.Version.ToString(); var...
C#’ta Çağıran Metod Bilgilerine Ulaşmak (CallerMemberName)
C# diliyle kodlama yaparken, zaman zaman bazı durumlarda, bir metodun hangi metoddan çağrıldığı, çağıran metod, bilgisine ulaşmamız gerekebiliyor. Örneğin loglama benim aklıma gelen durumlardan birisi, bir başka kullanım sebebi de, hatayı yakalamak olabilir. Bir...
sealed Keyword’ü Nedir? Ne İşe Yarar?
sealed keywordü bir class ve metod modifier(niteleyici)dır. Eğer bir class sealed komutuyla işaretlenmişse o classtan kalıtım yapılamaz. Yani o class başka bir sınıfın base classı olamaz. Ayriyetten bir metod sealed komutuyla işaretleniyorsa o metodtan...
MVC Get Attributes
Assembly assembly = Assembly.GetExecutingAssembly(); IEnumerable<Type> types = assembly.GetTypes() .Where( type => typeof(Controller).IsAssignableFrom(type) && type.Name.Replace("Controller", "") == controllerName) .OrderBy(x => x.Name); foreach (Type cls in types) { HelpAttribute helpAttribute = Attribute.GetCustomAttribute(cls, typeof(HelpAttribute)) as HelpAttribute; url...
MVC Get – Controllers, Actions, Attributes and Return Types – 2
Assembly assembly = Assembly.LoadFrom(sAssemblyFileName) IEnumerable<Type> types = assembly.GetTypes().Where(type => typeof(Controller).IsAssignableFrom(type)).OrderBy(x => x.Name); foreach (Type cls in types) { list.Add(cls.Name.Replace("Controller", "")); IEnumerable<MemberInfo> memberInfo = cls.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public).Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any()).OrderBy(x => x.Name); foreach...
MVC Get – Controllers, Actions, Attributes and Return Types
Assembly asm = Assembly.GetAssembly(typeof(MyWebDll.MvcApplication)); var controlleractionlist = asm.GetTypes() .Where(type=> typeof(System.Web.Mvc.Controller).IsAssignableFrom(type)) .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public)) .Where(m => !m.GetCustomAttributes(typeof( System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any()) .Select(x => new {Controller = x.DeclaringType.Name, Action = x.Name, ReturnType = x.ReturnType.Name,...
c# Mapping Class
public static class TypeExtensions { public static void MapTo<T, S>(this S source, T target) { Type sourceType = source.GetType(); Type targetType = target.GetType(); var sourceProperties = sourceType.GetProperties(); var targetProperties = targetType.GetProperties(); for (int i...
Class To Html Table
List<T> olan bir veriyi html çıktı olarak hazırlama…
Xml veriyi Class’a Atama
public static T SetXmlDataToViewModel&lt;T&gt;(T oViewModel, string xmlData) { if (string.IsNullOrEmpty(xmlData)) { return oViewModel; } XDocument dataXmlDoc = XDocument.Parse(xmlData); foreach (var prop in typeof(T).GetProperties()) { if (dataXmlDoc.Descendants().SingleOrDefault(p =&gt; p.Name.LocalName == prop.Name) != null) prop.SetValue(oViewModel, Convert.ChangeType(dataXmlDoc.Descendants().SingleOrDefault(p...
C# 6.0 Yenilikleri – Null-conditional operators
Null-conditional operators : Herhangi bir class veya propertyleri null ise bunlara erişmek için null kontrolü yapmadan çok daha basit yolla değerleri çekebiliriz. int? first = (customers != null) ? customers[0].Orders.Count() : null; Yukarıdaki kodun yerine...
C# 6.0 Yenilikleri – Exception filters
Exception filters : Yakalanan hatalara filitre konabilmektedir. Böylece belirtilen catch bloğunda sadece tanımlanan exception filtresine uygun exceptionlar yakalanır. Eğer hiçbir filitreye uymayan exception var ise stacktrace kaybolmadan işleme devam edilir. Aşağıdaki örnekte de görüldüğü gibi number değeri 50’den küçük...
C# 6.0 Yenilikleri – Declaration expressions
Declaration expressions : Expressionlar içerisinde artık tanımlama yapılabilmektedir. Ençok kullanıldığı yerler out parametreleridir. int.TryParse(number, out var x); public class Customer { public char[] Strings { get { return "a12b3d".ToCharArray(); } } public List<int> GetResult() { var...
C# 6.0 Yenilikleri – Extension methods
Extension methods : Extension methodlar projeye using ile eklenebilmektedir. using System.Linq.Enumerable; class Program { static void Main(string[] args) { var range = Range(5, 17); var odd = Where(range, i => i % 2 == 1);...
C# 6.0 Yenilikleri – Using static
Using static : Static class’lar using olarak projeye eklenebilmektedir. using System.Console; using System.Math; class Program { static void Main() { WriteLine(Sqrt(3*3 + 4*4)); } }
C# 6.0 Yenilikleri – Parameters on classes and structs
Parameters on classes and structs : Classlar oluşturulurken constructer olmadan parametre alması sağlanmıştır. public class RealCustomer(string firstName, string lastName) { public string FirstName { get; } = firstName; public string LastName { get; } = lastName;...
C# 6.0 Yenilikleri – Auto-property enhancements
Auto-property enhancements : Propertyler’e değer atanmaması durumunda default değer atanabilmektedir. public class Customer { public string FirstName { get; set; } = "Yakup"; public string LastName { get; set; } = "KALEBAŞI"; } Customer...
.Net Türkçe Tarih Sorununu Düzeltme
Bu işlemi yapabilmek için benim bulduğum iki yol var. Global.asax dosyasındaki "Application_BeginRequest" fonksiyonunun içeriğini aşağıdaki gibi düzenlemek yeterli olacaktır. Not: Hangi formata göre düzenleme yapacaksanız istediğiniz gibi fonksiyonun içeriğini ayarlayabilirsiniz. protected...
Biri “Wrapper” mı dedi :)
Diyelim bir kütüpane kullanıyorsunuz. Kendi yazdığımız kodun içinden direk o kütüpanenin kodlarına erişmek yerine araya girerek kendi sınıfınız içinden istediğiniz işlemleri kütüpaneye yaptırmaktır. Kullandığınız kütüphanelerin çoğu, genel amaçlar için yazılmıştır. Dolayısıyla, arayüzleri oldukça ayrıntılı, uzun...
Inline – Base64 Image Send Mail
MailMessage oMailMessage = new MailMessage(); int PictureId = 1; string ImgUrl = "Base64Data"; string cidPictureId = "picture" + PictureId; byte[] data = System.Convert.FromBase64String(ImgUrl); MemoryStream ms = new MemoryStream(data); string htmlBody = "<h3>Mail Body İçereği</h3><img...
SignalR Uygulama Örneği
http://jrdeveloperr.blogspot.com.tr/2013/05/signalr.html
Custom Functions with Entity Framework
http://blogs.msdn.com/b/efdesign/archive/2009/01/07/model-defined-functions.aspx http://stackoverflow.com/questions/25261731/custom-functions-with-entity-framework
AngularJS MVC Repository
http://www.codeproject.com/Articles/869433/AngularJS-MVC-Repository http://www.w3schools.com/angular/default.asp http://campus.codeschool.com/courses/shaping-up-with-angular-js/intro
Rijndael Şifreleme Algoritması
http://www.yazilimdilleri.net/YazilimMakale-2876-Rijndael-Sifreleme-Algoritmasi.aspx
Html Barkod
// JavaScript BarCode39 v. 1.0 (c) Lutz Tautenhahn, 2005 // The author grants you a non-exclusive, royalty free, license to use, // modify and redistribute this software. // This software is provided "as is",...
Nuget paket oluşturma ve yayınlama
Merhabalar, Microsoft.NET Paket yönetim aracı olan Nuget üzerinde bir paket oluşturma ve yayınlama aşamalarını anlatacağım. Paket yönetim platformları kendi yazdığınız ya da daha önce başkaları tarafından yazılan kütüphaneleri kolay ve merkezi olarak kulllanımını sağlar. Yazılım...
c# hata satır,method ve dosya bulma
// satır numarasına erişebilmek için true değerini atıyoruz StackTrace trace = new StackTrace(true); foreach (StackFrame frame in trace.GetFrames()) { if (!string.IsNullOrEmpty(frame.GetFileName())) { Console.WriteLine(frame.GetFileLineNumber()); Console.WriteLine(frame.GetMethod()); ...
UDP Send & Listening
Örnek uygulamalar: UDPListening UDPMessageSend
WCF Log tutmak için gerekli olan web.config ayarları
System.serviceModel içine eklenecek olan, </system.serviceModel> <diagnostics> <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" /> </diagnostics> </system.serviceModel> Web config içine System.diagnotics içeriği, <system.diagnostics> ...
WCF – MaxItemsInObjectGraph Error
http://blog.aggregatedintelligence.com/2011/01/wcf-maxitemsinobjectgraph-error.html
Visual Source Safe e Hızlı Bir Bakış
Visual SourceSafe ile çalışmak Çalışırken aslında ihtiyacınız olan ve bilmeniz gereken üç tane komut var, Check Out Check In Get Latest Version Check Out dosyanın düzenlenmesinin sizde olduğunu anlatır, böylece başkası dosya üzerinde işlem yapamaz...
pdf Dosyası oluşturma
http://www.yazgelistir.com/makale/itextsharp-kutuphanesi-ile-pdf-dosyasinda-raporlar-olusturmak
Dictionary, Literal ve Serialization kullanımı
Dictionary, Literal ve Serialization kullanımı için örnek dosya ornek_1
C# Temel bilgiler . . .
C# sealed Anahtar Sözcüğü => http://onursalkaya.blogspot.com.tr/2011/12/c-sealed-anahtar-sozcugu.html C# Inheritance => http://onursalkaya.blogspot.com.tr/2011/03/c-inheritance.html
Kalıtım (Inheritance) Nedir ve Nasıl Kullanılır
http://www.kodadiyazilimci.com/Makale/Index/makale/Csharp-Kalitim–Inheritance–Nedir-ve-Nasil-Kullanilir
CollectionPager İle Repeater veya DataList İle Sayfalama
http://www.codeproject.com/Articles/9797/Pager-Control-for-Repeater-DataList-or-an-Enumerab
c# APIs :)
http://www.pinvoke.net/