Skip to main content

Posts

Web API file upload set filename

By default when you upload files using ASP.NET Web API, the files are saved using a random filename. This is not a bug, but a security decision Microsoft made. They considered it a security risk to take the file name provided in the Content-Disposition header field and decided  instead to compute a file name. You can easily solve this by deriving from the default MultiPartFormDataStreamProvider and provide your own naming mechanism: If you want to know some more about uploading files using Web API, I recommend the following blog post: A guide to asynchronous file uploads in ASP.NET Web API RTM

Running web deploy from the command line: some useful commands

I talked about Web Deploy before. It allows you to easily deploy your web applications to IIS without much overhead. I use it most of the time. Last week I asked the server administrator to enable the automatic backup feature on the web server.  Once I got the confirmation email that it was configured, I did a new deployment to test the backup feature. After the deployment completed succesfully, I opened a command prompt and browsed to C:\Program Files (x86)\IIS\Microsoft Web Deploy V3. Print the list of backups I used the following command to dump the list of created backups: msdeploy -verb:dump -source:backupManager="development.customer.be/appname",computerName="serverXX",userName="UserXYZ",password="PasswordXYZ" But the output window returned nothing. No backups were created. Print the backup settings I switched to another command to dump the backupSettings from the server: msdeploy -verb:dump -source:backupSett...

Windows 8: Load html in a webview control

In a Windows 8 application I added a WebView control to load some local HTML files. I started by setting the source property of the WebView control to the HTML page I embedded into the application: DisclaimerWebView.Source = new Uri("ms-appx-web:///assets/disclaimer.html"); But when I ran the application, I saw an empty WebView control. So I switched to the  WebView.Navigate method: DisclaimerWebView.Navigate(new Uri("ms-appx-web:///assets/disclaimer.html")); No effect… After a while I found the reason. I had to explicitly set the Width and the Height of the WebView control. And finally my HTML was loaded.

SOA: the first rule of versioning web services

One important element in building a good SOA(Service Oriented Architecture) is creating a good versioning approach. If you fail to get good versioning from the start, It will become really hard to fix it afterwards. So therefore remember the first rule of versioning web services:   “One object in, One object out”   What does it mean? Let’s explain with the following sample. Imagine I created a webservice with the following method: This is a hard to version service and a really bad example. Why? Because we are using a simple type as input(in this case a guid). This means that in this case we have one object out, but not one object in. If later we have to add a second input parameter, we’ll end up with a breaking change. A better alternative is to use the following contract: Now we have one object in, one object out. If we want to send some extra data, we can just add it to the OrderRequest object as an extra property.

Here's why HTML-based apps don't work

I’m currently working on a cross-platform solution using Xamarin . Today a colleague sent me a link to the following article: Here's why HTML-based apps don't work . In this article Matt Baxter-Reynolds who worked on a number of different projects based on PhoneGap/Apache Cordova shares his experiences. There is one quote(and the conclusion of the article) that I want to share with you: “Go native, try Xamarin . But in terms of hybrid: avoid.” I’m just saying…

Where is the Add STS reference option in Visual Studio 2012?

In Visual Studio 2012 the Add STS reference… option is replaced by a completely new tool: The Identity and Access Tool . The Identity and Access Tool for Visual Studio 2012 enables you to secure your application with claims based identity and accept users from multiple identity providers. This extension adds a context sensitive project menu entry to easily add identity capabilities to your Web Applications, MVC Applications and WCF Services. This will provide you with capabilities for developing and testing your application with a Local Development STS, connecting to a corporate identity provider like ADFS2 and using the Windows Azure Access Control Service to connect to other identity provides such as LiveID, Google, Yahoo and Facebook. It does this by updating your web.config file with the proper settings to enable the Windows Identity Foundation in .NET 4.5 and adding the necessary configuration for the identity provider you select. This tool is not available out-of-the-...

ASP.NET MVC 4: the _references.js file

When creating a new ASP.NET MVC 4 project, I noticed that a  _references.js file was added to the Scripts folder. If we look at the content, I only see some comments. So what is it good for? The VS <reference /> Syntax The // <reference path=”…” /> allows you to enable IntelliSense in any JavaScript file by including everything defined in the JavaScript located at this path.Visual Studio 2012 will give you IntelliSense for all files that have references in the “_references.js” file. This way you can enable IntelliSense for the JavaScript files you use all the time. If you want, you can add your own files too: Go to Tools –> Options. Browse in the Tree view to Text Editor –> JavaScript –> IntelliSense –> References Here you can add other script files containing reference paths