Wednesday, April 27, 2016

Use “runas” when testing different user roles

A common scenario when testing SharePoint is to switch between multiple user accounts to imitate different user roles. A normal way to do this is to use SharePoints “sign in as a different user” function or right click on a browser/program and use the “run as a different user” function in windows.

The first method can result in you are sign in as the current user when you are browsers other resources dependent on your internet explorer settings.

The second will solve this problem. But you need to enter username and password each time you start a new browser session.

To overcome you need to enter username and password each time. You can use the “runas” program call from a .bat file. With the syntax like this, can you indicate the username. And you only need to enter the password the first time you run the .bat file:

runas /user:[domain\username] /savecred “[path to browser/program]”


runas /user:domain\SP13TestAO1 /savecred "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

And create a .bat file for each user role, it is easy to switch between user session:


Monday, April 25, 2016

WebAPI plain text response

I got a problem where the solution was to create a globe JavaScript object and I need to render the data on the server.

I would like to use the JavaScript object like:

<span id="text"></span>
var d = document.getElementById("text");
d.innerText = resources.hello;

I started by creating a WebAPI controller and return a string through the Ok method. And end up with this:


This is not JavaScript and there for I can’t use it.

I found an article by Mike Wasson ( Where he creates a new IHttpActionResult.

With this new class. I can control the output. So it will be like this: