19 Eylül 2019 Perşembe
JavaScript or JQuery redirect to URL on select
JavaScript:
<select onChange="window.document.location.href=this.options[this.selectedIndex].value;">
<option vlaue="http://deneme.com/">Option 1</option>
<option vlaue="http://deneme.net/">Option 2</option>
<option vlaue="http://deneme.org/">Option 3</o
jQuery:
jQuery(function($) {
$('select').on('change', function() {
var url = $(this).val();
if (url) {
window.location = url;
}
return false;
});
});
18 Eylül 2019 Çarşamba
Web sayfasında geri tuşunu pasif etmek ...
history.pushState(null, null, location.href);
window.addEventListener('popstate', function (event) {
// The popstate event is fired each time when the current history entry changes.
var r = false;// confirm("Geri butonu çalışmayacak..?!");
if (r == true) {
// Call Back button programmatically as per user confirmation.
history.back();
// Uncomment below line to redirect to the previous page instead.
// window.location = document.referrer // Note: IE11 is not supporting this.
} else {
// Stay on the current page.
history.pushState(null, null, window.location.pathname);
}
history.pushState(null, null, window.location.pathname);
}, false);
window.addEventListener('popstate', function (event) {
// The popstate event is fired each time when the current history entry changes.
var r = false;// confirm("Geri butonu çalışmayacak..?!");
if (r == true) {
// Call Back button programmatically as per user confirmation.
history.back();
// Uncomment below line to redirect to the previous page instead.
// window.location = document.referrer // Note: IE11 is not supporting this.
} else {
// Stay on the current page.
history.pushState(null, null, window.location.pathname);
}
history.pushState(null, null, window.location.pathname);
}, false);
6 Ağustos 2019 Salı
c# Web Sayfasının URL bulunması (Get IIS Url)
Farklı sunucularda local dosya erişimde parametrik yapıdan ziyade IIS üzerindeki url ile dosya erişim yapmak için ;
var url = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority);
response = "http://localhost:59386/"
var url = HttpContext.Request.Url.GetLeftPart(UriPartial.Authority);
response = "http://localhost:59386/"
12 Nisan 2019 Cuma
C# DLL P/Invoke CallbackOnCollectedDelegate Error
Mevcut C++ ile yazılmış bir dll projenize eklemek için ara dll oluşturarak yapacağınız Callback uygulamalarında GC callback metodunu kaldırması sorunucu çalışma aralığında CallbackOnCollectedDelegate Exception alıp uygulama kapanmasına neden olmaktadır.
Sorun:
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void ApplicationMessageCallback(Int32 applicationId, IntPtr data, Int32 size);
[DllImport("xxx.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void inposext_set_application_message_callback(ApplicationMessageCallback cb);
public static void SetApplicationMessageCallback(ApplicationMessageCallback callbackFunction)
{
inposext_set_application_message_callback(callbackFunction);
}
Çözüm :
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void ApplicationMessageCallback(Int32 applicationId, IntPtr data, Int32 size);
[DllImport("xxx.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void inposext_set_application_message_callback(ApplicationMessageCallback cb);
private static ApplicationMessageCallback callback; // Keeps it referenced
public static void SetApplicationMessageCallback(ApplicationMessageCallback callbackFunction)
{
callback = callbackFunction;
inposext_set_application_message_callback(callback);
}
Etiketler:
C#,
CallbackOnCollectedDelegate,
INVOKE
17 Şubat 2019 Pazar
C# SeriPort Ad okuma
using (var searcher = new System.Management.ManagementObjectSearcher
("SELECT * FROM WIN32_SerialPort"))
{
string[] portnames = System.IO.Ports.SerialPort.GetPortNames();
var ports = searcher.Get().Cast<System.Management.ManagementBaseObject>().ToList();
var tList = (from n in portnames
join p in ports on n equals p["DeviceID"].ToString()
select n + " - " + p["Caption"] ).ToList();
tList.ForEach(Console.WriteLine);
}
("SELECT * FROM WIN32_SerialPort"))
{
string[] portnames = System.IO.Ports.SerialPort.GetPortNames();
var ports = searcher.Get().Cast<System.Management.ManagementBaseObject>().ToList();
var tList = (from n in portnames
join p in ports on n equals p["DeviceID"].ToString()
select n + " - " + p["Caption"] ).ToList();
tList.ForEach(Console.WriteLine);
}
16 Ocak 2019 Çarşamba
system diagnostics process start administrator
system diagnostics process start administrator:
Process proc = new Process();
proc.StartInfo.FileName = fileName;
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";
proc.Start();
19 Kasım 2018 Pazartesi
Visual Studio- Hata : the underlying connection was closed an unexpected error occurred on a send and (407) Proxy Authentication Required.
Güvenli bir ağ üzerinden proxy yetkilendirmeli bir ağdan dış servise bağlanma sırasında alınan hata cözümü :
app.config eklen
Clinet Kullanmadan önce aşağıdaki kodu uygun bir yere yerleştirin . TLS 1.2 için
System.Net.ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)3072;
If you are stuck with .Net 4.0 and the target site is using TLS 1.2, you need the following line instead.
app.config eklen
<system.net>
<defaultProxy useDefaultCredentials="true" >
</defaultProxy>
</system.net>
Clinet Kullanmadan önce aşağıdaki kodu uygun bir yere yerleştirin . TLS 1.2 için
System.Net.ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)3072;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
Kaydol:
Kayıtlar (Atom)