Tag: Logon

Azure Mobile Services prompt for login when clicking on ‘try it out’

Could not work out how what to do about this, but found this solution (http://blogs.msdn.com/b/musings_on_alm_and_software_development_processes/archive/2014/10/23/azure-mobile-services-prompts-you-for-a-username-and-password.aspx).

Use one of your access keys in the password field, leaving the username blank.

Then you can browse to the /help url for your mobile service.

.Net MVC 3 Logon does not redirect out the box–quick fix!

It seems that the templates for MVC 3 razor are not quite complete. If you attempt to browse to a page where authentication is required, then you will be redirect to the Logon page with a ReturnUrl query string.

Something like:


That’s great except, out the box, the Logon page does not make use of this and the destination page is not redirected to after a successful login. The fix is easy.

Add the returnUrl route value into the Html.BeginForm method as shown below.

Html.BeginForm("LogOn", "Account", new { returnUrl = Request.QueryString["ReturnUrl"] })

You should already have some code in the controller that does some sanity checking on the returnUrl before doing the redirect. Somthing like:

if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
       && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
    return Redirect(returnUrl);

Make sure this is after the SetAuthCookie line!