4

For an ASP.NET SPA app, the code template that ships with VS2013 is very different from the code template that ships with VS2013 Updates 2/3/4. For reference, here's the same template from

VS2013: https://www.dropbox.com/s/nc9t691adg2q9ac/OldTemplate.zip?dl=0

VS2013 update 4: https://www.dropbox.com/s/sk8qajyxy4kx4m3/NewTemplate.zip?dl=0

The biggest difference seems to be that logging in with the original template is done without a postback, entirely through JavaScript (which seems to keep with the SPA spirit). But in the later version of the template, a full postback happens during login. There is a plethora of other changes that seem connected to this main change, for example, in the older version there exists this method inside ApplicationOAuthProvider.cs:

public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
    {
        using (UserManager<IdentityUser> userManager = _userManagerFactory())
        {
            IdentityUser user = await userManager.FindAsync(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "The user name or password is incorrect.");
                return;
            }

            ClaimsIdentity oAuthIdentity = await userManager.CreateIdentityAsync(user,
                context.Options.AuthenticationType);
            ClaimsIdentity cookiesIdentity = await userManager.CreateIdentityAsync(user,
                CookieAuthenticationDefaults.AuthenticationType);
            AuthenticationProperties properties = CreateProperties(user.UserName);
            AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties);
            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);
        }
    }

This method is completely omitted from the newer template.

Would appreciate any insight as to why such significant changes were made. I don't see any advantages, and for a SPA-style app I prefer the lack of postback. But perhaps there were important security or design reasons considered which I should also consider.

Thanks... -Ben

BenjiFB
  • 4,545
  • 10
  • 46
  • 53
  • Browsing through the unanswered tab. I'll be taking a guess in the answer but please be aware that we are now almost 1 year after and the ASP.NET 5 RC1 is officially out. – Maxime Rouiller Nov 19 '15 at 18:41

1 Answers1

0

My guess would be that it was an oversight or lack of time.

I'm sorry if it's not the most glamorous of answers filled with code samples... but the SPA template is not the most used scenario when you do File > New Project.

I can see why it wouldn't get as much as as WebApplication for example.

If you are interested in templates, I would suggest taking a look at SideWaffle which contains tons of templates that could help you get bootstrapped.

Maxime Rouiller
  • 13,614
  • 9
  • 57
  • 107