I'm trying to learn IS4 at the moment, there's 3 projects in my solution: API, .NET MVC and IS4. My problem is when I starts the project, it redirect to IS4's login page, without going to the home page of the application. What did I do wrong?
I set the solution to start API, IS4, MVC - in that order:
And when the MVC project starts, I believe I set it to start at the home page:
And this is my controller's Index action:
[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)));
}
}
}
How/why did it redirect straight away to IdentityServer's login page, skipping the Index page?
I don't think you are doing anything wrong. The [Authorize]
attribute on your home page's controller will cause a redirect to IS to authenticate the user.