24 Şubat 2017 Cuma

WcfTestClient.exe lokasyon

For .NET 4.5+:
C:\Program Files (x86)\Microsoft Visual Studio {YourVersionHere}\Common7\IDE
VS 2015:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
VS 2013:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE
VS 2012:
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE

23 Şubat 2017 Perşembe

File upload using MVC 4 with Ajax

ere is my small working sample, which uploads multiple files and uploads in a folder called as 'junk'
Client Side....
    <html>
    <head>
    <title>Upload Example</title>
    <script src="~/Scripts/jquery-2.1.0.intellisense.js"></script>
    <script src="~/Scripts/jquery-2.1.0.js"></script>
    <script src="~/Scripts/jquery-2.1.0.min.js"></script>
    <script>
    $(document).ready(function () {
        $("#Upload").click(function () {
            var formData = new FormData();
            var totalFiles = document.getElementById("FileUpload").files.length;
            for (var i = 0; i < totalFiles; i++)
            {
                var file = document.getElementById("FileUpload").files[i];

                formData.append("FileUpload", file);
            }
            $.ajax({
                type: "POST",
                url: '/Home/Upload',
                data: formData,
                dataType: 'json',
                contentType: false,
                processData: false,
                success: function (response) {
                    alert('succes!!');
                },
                error: function (error) {
                    alert("errror");
                }
            });
        });
    });

</script>
</head>
<body>
    <input type="file" id="FileUpload" multiple />
    <input type="button" id="Upload" value="Upload" />
</body>
</html>
Server Side....
public class HomeController : Controller
{
    [HttpPost]
    public void Upload( )
    {
        for( int i = 0 ; i < Request.Files.Count ; i++ )
        {
            var file = Request.Files[i];

            var fileName = Path.GetFileName( file.FileName );

            var path = Path.Combine( Server.MapPath( "~/Junk/" ) , fileName );
            file.SaveAs( path );    
        }

    }
}

21 Şubat 2017 Salı

Asp .Net MVC tarih, sayı format sorunu

protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
        {
         
            string cultureName;

            // Attempt to read the culture cookie from Request
            var cultureCookie = Request.Cookies["_culture"];
            if (cultureCookie != null)
                cultureName = cultureCookie.Value;
            else
                cultureName = Request.UserLanguages != null && Request.UserLanguages.Length > 0 ?
                        Request.UserLanguages[0] :  // obtain it from HTTP header AcceptLanguages
                        null;
            // Validate culture name
            cultureName = CultureHelper.GetImplementedCulture(cultureName); // This is safe

            // Modify current thread's cultures          
            var currentCulture = new CultureInfo(cultureName)
            {
                DateTimeFormat =
                {
                    ShortDatePattern = "dd/MM/yyyy",
                    DateSeparator = "/"
                },
                NumberFormat =
                {
                    NumberDecimalDigits = 4,
                    NumberDecimalSeparator = ".",
                    NumberGroupSeparator = ","
                }
            };
            Thread.CurrentThread.CurrentCulture = currentCulture;
            Thread.CurrentThread.CurrentUICulture = currentCulture;
            return base.BeginExecuteCore(callback, state);
        }

15 Şubat 2017 Çarşamba

asp net mvc - datetime sorunu

protected void Application_PreRequestHandlerExecute()
        {
            var currentCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
            currentCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
            currentCulture.DateTimeFormat.DateSeparator = "/";
            Thread.CurrentThread.CurrentCulture = currentCulture;
            Thread.CurrentThread.CurrentUICulture = currentCulture;
        }

.net 6 mapget kullanımı

 app.UseEndpoints(endpoints => {     endpoints.MapGet("/", async context =>     {         var response = JsonConvert.Seriali...