大约一个月前,我有一个项目与ASP Identity OAuth完美配合.我将使用grant_type,username和password向/ Token端点发送POST请求,所有这些都是花花公子.
我最近开始了一个基于Visual Studio 2013 RC2的SPA模板的新项目.它与旧模板有点不同.身份验证设置为非常基本的默认值,
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
//AuthorizeEndpointPath = new PathString("/Account/Authorize"),
Provider = new ApplicationOAuthProvider(PublicClientId),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
};
Run Code Online (Sandbox Code Playgroud)
默认模板没有任何重大变化.我可以通过我实现的Web API控制器方法成功注册帐户;
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
public async Task<IHttpActionResult> Register(RegisterBindingModel model)
{
if (ModelState.IsValid)
{
var user = new TunrUser() { UserName = model.Email, Email = model.Email, DisplayName = model.DisplayName };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
return Created(new Uri("/api/Users/" + user.Id,UriKind.Relative), user.toViewModel());
} …Run Code Online (Sandbox Code Playgroud) c# asp.net asp.net-web-api asp.net-identity asp.net-web-api2
我有一个正在部署到 Azure 的 ASP.NET Core 应用程序,该应用程序在 URL 中接收包含冒号(时间戳)的字符串。
例如:http://localhost:5000/Servers/208.100.45.135/28000/2017-03-15T07:03:43+00:00,或http://localhost:5000/Servers/208.100.45.135/28000/2017-03-15T07%3a03%3a43%2B00%3a00URL 编码。
使用 Kestrel ( ) 在本地运行时效果非常好dotnet run,但在部署到 Azure 后我收到此错误:The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
快速搜索发现,这是由于 URL 中使用了无效字符(即冒号)造成的。传统的修复方法是将此部分添加到web.config:
<system.web>
<httpRuntime requestPathInvalidCharacters="" />
</system.web>
Run Code Online (Sandbox Code Playgroud)
但是,将其添加到 Azure 上的 web.config 后,我发现没有任何变化。我想这是由于 ASP.NET Core 托管模型的差异造成的。
这是我目前的web.config:
<configuration>
<system.web>
<httpRuntime requestPathInvalidCharacters=""/>
<pages validateRequest="false" />
</system.web>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers> …Run Code Online (Sandbox Code Playgroud)