It’s really nice to see the cadence Microsoft is getting up to with their release cycle. Yesterday a new version of the Office 365 API Tools (1.1.728) was release that improves on the previous releases (not so much if you are using it in a web application, it seems like most improvements are for the client libraries and for phonegap).
Nevertheless I just took it for a quick spin in a MVC application as I have done with with the previous releases too. The first thing you will notice, if you try to add e.g. the MailApiSample to a simple MVC list view controller, is that you get an exception like this
[RedirectRequiredException: The browser must be redirected to a new URL.]
What the eck, they changed how the auth-flow is working. I’m not sure I agree with this change of using Exceptions to handle the typical Auth-flow, but I will have to spend some more time investigating what else have been changed before I make my verdict.
Anyways in order to correctly sign in you have to wrap your call to the MailApiSample (or MyFiles) in a try/catch and handle the
RedirectRequiredException so my simple mail controller looks like this.
public class MailController : Controller
// GET: Mail
public async Task<ActionResult> Index()
var messages = await MailApiSample.GetMessages();
catch (RedirectRequiredException ex)
If you want to read more check Chakkaradeep Chandran’s blog post and the official annoucement. It sounds like we are closing in on a non-preview version, I’m looking forward to that!
Categories: Office SharePoint
Thanks for the post Simon. I am new to this, so please excuse me if the question sounds dumb…I tried to catch the exception, but the sample above doesn’t compile. RedirectRequiredException is an unknown type…is there a ‘using’ that I am missing? Here’re the namespaces that I am referencing:
Hi Murali, I updated the sample to include the required using statements, sorry for the inconvenience