问题描述
此刻我正在尝试学习IS4,我的解决方案中有3个项目:API,.NET MVC和IS4。我的问题是,当我启动该项目时,它重定向到IS4的登录页面,而不转到应用程序的主页。我做错了什么?
我将解决方案设置为按以下顺序启动API,IS4,MVC:
这是我的控制器的Index操作:
[Authorize]
public class galleryController : Controller
{
public async Task<IActionResult> Index()
{
//await WriteOutIdentityinformation();
var httpClient = _httpClientFactory.CreateClient("apiclient");
var request = new HttpRequestMessage(
HttpMethod.Get,"/api/images/");
var response = await httpClient.SendAsync(
request,HttpCompletionoption.ResponseHeadersRead).ConfigureAwait(false);
response.EnsureSuccessstatusCode();
using (var responseStream = await response.Content.ReadAsstreamAsync())
{
return View(new galleryIndexviewmodel(
await JsonSerializer.DeserializeAsync<List<Image>>(responseStream)));
}
}
}
它如何/为什么直接重定向到IdentityServer的登录页面,而跳过“索引”页面?
解决方法
我认为您没有做错任何事情。主页控制器上的[Authorize]
属性将导致重定向到IS来验证用户身份。