我有ASP.NET REST服务,它运行得非常快和良好,除了授权之外,我使用的是基于Owin.Security的standart auth,如下所示:
public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context and user manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Configure the application for OAuth based flow
PublicClientId = "self";
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(10),
AllowInsecureHttp = true,
};
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);}
我没有改变任何东西,它是从模板项目,它工作良好,除了时间。它需要大约30秒的时间才能从服务器上取回一个承载令牌。我对ASP.NET开发非常陌生,我不知道为什么它这么长,我在我的数据库中有10个用户和3个角色,我确信它可以工作得更快,但不知道怎么做
其他rest请求(POST、GET)工作速度快、运行良好,/Token请求只需30秒
,我已经重新发布了我的服务器解决方案,现在要花费3到30秒的时间才能得到令牌,这是非常奇怪的行为,不是吗?
发布于 2015-11-17 13:18:14
1)如果在应用程序启动后立即请求令牌,那么在任何控制器方法的第一次执行之前都会发生一些应用程序初始化逻辑。
2)如果您使用的是远程SQL server实例,这会导致长时间的请求处理。尝试使用本地SQL服务器进行本地分析。
https://stackoverflow.com/questions/30062169
复制相似问题