问题描述
有关一个ASP.NET应用程序的SPA,在code ++模板附带VS2013是从code ++模板非常不同的附带VS2013更新2/3/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:
VS2013更新4:
VS2013 update 4: https://www.dropbox.com/s/sk8qajyxy4kx4m3/NewTemplate.zip?dl=0
最大的区别,似乎是与原始模板登录时不回发做,完全是通过JavaScript(这似乎跟上SPA精神)。但在模板的后续版本,一个完整的回传登录期间发生的。还有就是,似乎连接到这个主要的变化,比如其它变化过多,在旧版本存在内部ApplicationOAuthProvider.cs此方法:
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.
应该AP preciate任何见解,为什么这样显著进行了更改。我看不到任何优势,而对于SPA-风格的应用程序我preFER缺乏回传的。但是,也许有重要的安全性或设计上的原因考虑,我也应该考虑。
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.
谢谢...
-ben
Thanks...-Ben
推荐答案
我的猜测是,这是一个疏忽或缺乏时间。
My guess would be that it was an oversight or lack of time.
我很抱歉,如果它不是最迷人的充满code样品的答案......但SPA模板,是不是当你做文件&gt最常用的场景;新建项目
。
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
.
我明白为什么它不会获得尽可能多的为的WebApplication
例如
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.
这篇关于原因在ASP.NET SPA模板更改为ASP.NET身份code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!