Azure Ad authentication not working for new asp.net core 2.1 with angular 5.2 new template. Since we do not...
We have migrated our .net core 2.1 with angular 4.3 to .net core 2.1 with angular 5.2.
Now we are not able to do azure ad authentication from startup.cs as there is change in MapRoute defination. For refrence,
Previous:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
latest:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
Previously we used to navigate to home controller and index.cshtml after authentication. But now there is no .cshtml in new template.
c# jquery angular visual-studio-2017 asp.net-core-2.1
add a comment |
We have migrated our .net core 2.1 with angular 4.3 to .net core 2.1 with angular 5.2.
Now we are not able to do azure ad authentication from startup.cs as there is change in MapRoute defination. For refrence,
Previous:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
latest:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
Previously we used to navigate to home controller and index.cshtml after authentication. But now there is no .cshtml in new template.
c# jquery angular visual-studio-2017 asp.net-core-2.1
Hi vikas ! I'm also facing the same problem migrating my app to this new project template where there is no more cshtml file...Did you solve your problem ?
– homega52
Jan 31 at 10:58
Yes i have solved the problem. What problem you are facing?
– vikas biradar
Feb 1 at 5:23
I posted my solution. Did you use the same method ?
– homega52
Feb 1 at 14:05
add a comment |
We have migrated our .net core 2.1 with angular 4.3 to .net core 2.1 with angular 5.2.
Now we are not able to do azure ad authentication from startup.cs as there is change in MapRoute defination. For refrence,
Previous:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
latest:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
Previously we used to navigate to home controller and index.cshtml after authentication. But now there is no .cshtml in new template.
c# jquery angular visual-studio-2017 asp.net-core-2.1
We have migrated our .net core 2.1 with angular 4.3 to .net core 2.1 with angular 5.2.
Now we are not able to do azure ad authentication from startup.cs as there is change in MapRoute defination. For refrence,
Previous:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
latest:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
Previously we used to navigate to home controller and index.cshtml after authentication. But now there is no .cshtml in new template.
c# jquery angular visual-studio-2017 asp.net-core-2.1
c# jquery angular visual-studio-2017 asp.net-core-2.1
asked Jan 2 at 7:30
vikas biradarvikas biradar
1138
1138
Hi vikas ! I'm also facing the same problem migrating my app to this new project template where there is no more cshtml file...Did you solve your problem ?
– homega52
Jan 31 at 10:58
Yes i have solved the problem. What problem you are facing?
– vikas biradar
Feb 1 at 5:23
I posted my solution. Did you use the same method ?
– homega52
Feb 1 at 14:05
add a comment |
Hi vikas ! I'm also facing the same problem migrating my app to this new project template where there is no more cshtml file...Did you solve your problem ?
– homega52
Jan 31 at 10:58
Yes i have solved the problem. What problem you are facing?
– vikas biradar
Feb 1 at 5:23
I posted my solution. Did you use the same method ?
– homega52
Feb 1 at 14:05
Hi vikas ! I'm also facing the same problem migrating my app to this new project template where there is no more cshtml file...Did you solve your problem ?
– homega52
Jan 31 at 10:58
Hi vikas ! I'm also facing the same problem migrating my app to this new project template where there is no more cshtml file...Did you solve your problem ?
– homega52
Jan 31 at 10:58
Yes i have solved the problem. What problem you are facing?
– vikas biradar
Feb 1 at 5:23
Yes i have solved the problem. What problem you are facing?
– vikas biradar
Feb 1 at 5:23
I posted my solution. Did you use the same method ?
– homega52
Feb 1 at 14:05
I posted my solution. Did you use the same method ?
– homega52
Feb 1 at 14:05
add a comment |
2 Answers
2
active
oldest
votes
This is probably because of the reply URL.
When authentication is performed, user is redirected to the reply URL.
This URL is configured in AAD.
You may have configured the root URL of application in reply URL which does not contain any controller or action. That's why application is not able to route request to anywhere.
You can verify this in Azure Portal.
EDIT:
Based on your comment, i would suggest to check if you have used "UseDefaultFiles".
UseDefaultFiles tries to find a page with name "Default" or "Index". But if page with these names are not available, then you need to write custom logic.
Let's say you want to make "mydefault.html" as default document then the logic would be as below.
Refer this documentation.
public void Configure(IApplicationBuilder app)
{
// Serve my app-specific default file, if present.
DefaultFilesOptions options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("mydefault.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
}
Actually it is not going to the Microsoft login page as the new template has been changed. Previously we use to have index.cshtml. But now there is no view available in new templates. I think as per new template we need to write authentication on client side only. Waiting for your reply
– vikas biradar
Jan 2 at 9:54
I hope you have used app.UseDefaultFiles() in the startup configure method. This method looks for page with name "Default" or "Index" if no page is specified. But if you dont have pages with these names then you need to tell this method which should be default page. Edited my original answer to provide answer.
– Manoj Choudhari
Jan 2 at 9:57
Thank you manoj for reply. But the issue is authenticating to login.microsoftonline.com in startup.cs file. Previously it was working with home controller and index.cdshtml. But now the new template does not have view folder. instead of which we haves pages folder.
– vikas biradar
Jan 2 at 10:14
can you check in fiddler on what is happening ? You can check request is failing to reach your web server OR it is failing when trying to reach Azure AD url (login.microsoftonline.com). That would help you to confirm the exact issue.
– Manoj Choudhari
Jan 2 at 10:17
add a comment |
I faced the exact same problem migrating my app from angular 5/.Net Core 2.0 to angular 7/.Net Core 2.2 and i found a way to keep the authentication server side.
The solution for that is to add a middleware that check if every request is authenticated and if it's not the case, force it.
app.Use(async (context, next) =>
{
if (!context.User.Identity.IsAuthenticated)
{
await context.ChallengeAsync();
}
else
{
await next();
}
});
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54002724%2fazure-ad-authentication-not-working-for-new-asp-net-core-2-1-with-angular-5-2-ne%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is probably because of the reply URL.
When authentication is performed, user is redirected to the reply URL.
This URL is configured in AAD.
You may have configured the root URL of application in reply URL which does not contain any controller or action. That's why application is not able to route request to anywhere.
You can verify this in Azure Portal.
EDIT:
Based on your comment, i would suggest to check if you have used "UseDefaultFiles".
UseDefaultFiles tries to find a page with name "Default" or "Index". But if page with these names are not available, then you need to write custom logic.
Let's say you want to make "mydefault.html" as default document then the logic would be as below.
Refer this documentation.
public void Configure(IApplicationBuilder app)
{
// Serve my app-specific default file, if present.
DefaultFilesOptions options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("mydefault.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
}
Actually it is not going to the Microsoft login page as the new template has been changed. Previously we use to have index.cshtml. But now there is no view available in new templates. I think as per new template we need to write authentication on client side only. Waiting for your reply
– vikas biradar
Jan 2 at 9:54
I hope you have used app.UseDefaultFiles() in the startup configure method. This method looks for page with name "Default" or "Index" if no page is specified. But if you dont have pages with these names then you need to tell this method which should be default page. Edited my original answer to provide answer.
– Manoj Choudhari
Jan 2 at 9:57
Thank you manoj for reply. But the issue is authenticating to login.microsoftonline.com in startup.cs file. Previously it was working with home controller and index.cdshtml. But now the new template does not have view folder. instead of which we haves pages folder.
– vikas biradar
Jan 2 at 10:14
can you check in fiddler on what is happening ? You can check request is failing to reach your web server OR it is failing when trying to reach Azure AD url (login.microsoftonline.com). That would help you to confirm the exact issue.
– Manoj Choudhari
Jan 2 at 10:17
add a comment |
This is probably because of the reply URL.
When authentication is performed, user is redirected to the reply URL.
This URL is configured in AAD.
You may have configured the root URL of application in reply URL which does not contain any controller or action. That's why application is not able to route request to anywhere.
You can verify this in Azure Portal.
EDIT:
Based on your comment, i would suggest to check if you have used "UseDefaultFiles".
UseDefaultFiles tries to find a page with name "Default" or "Index". But if page with these names are not available, then you need to write custom logic.
Let's say you want to make "mydefault.html" as default document then the logic would be as below.
Refer this documentation.
public void Configure(IApplicationBuilder app)
{
// Serve my app-specific default file, if present.
DefaultFilesOptions options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("mydefault.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
}
Actually it is not going to the Microsoft login page as the new template has been changed. Previously we use to have index.cshtml. But now there is no view available in new templates. I think as per new template we need to write authentication on client side only. Waiting for your reply
– vikas biradar
Jan 2 at 9:54
I hope you have used app.UseDefaultFiles() in the startup configure method. This method looks for page with name "Default" or "Index" if no page is specified. But if you dont have pages with these names then you need to tell this method which should be default page. Edited my original answer to provide answer.
– Manoj Choudhari
Jan 2 at 9:57
Thank you manoj for reply. But the issue is authenticating to login.microsoftonline.com in startup.cs file. Previously it was working with home controller and index.cdshtml. But now the new template does not have view folder. instead of which we haves pages folder.
– vikas biradar
Jan 2 at 10:14
can you check in fiddler on what is happening ? You can check request is failing to reach your web server OR it is failing when trying to reach Azure AD url (login.microsoftonline.com). That would help you to confirm the exact issue.
– Manoj Choudhari
Jan 2 at 10:17
add a comment |
This is probably because of the reply URL.
When authentication is performed, user is redirected to the reply URL.
This URL is configured in AAD.
You may have configured the root URL of application in reply URL which does not contain any controller or action. That's why application is not able to route request to anywhere.
You can verify this in Azure Portal.
EDIT:
Based on your comment, i would suggest to check if you have used "UseDefaultFiles".
UseDefaultFiles tries to find a page with name "Default" or "Index". But if page with these names are not available, then you need to write custom logic.
Let's say you want to make "mydefault.html" as default document then the logic would be as below.
Refer this documentation.
public void Configure(IApplicationBuilder app)
{
// Serve my app-specific default file, if present.
DefaultFilesOptions options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("mydefault.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
}
This is probably because of the reply URL.
When authentication is performed, user is redirected to the reply URL.
This URL is configured in AAD.
You may have configured the root URL of application in reply URL which does not contain any controller or action. That's why application is not able to route request to anywhere.
You can verify this in Azure Portal.
EDIT:
Based on your comment, i would suggest to check if you have used "UseDefaultFiles".
UseDefaultFiles tries to find a page with name "Default" or "Index". But if page with these names are not available, then you need to write custom logic.
Let's say you want to make "mydefault.html" as default document then the logic would be as below.
Refer this documentation.
public void Configure(IApplicationBuilder app)
{
// Serve my app-specific default file, if present.
DefaultFilesOptions options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("mydefault.html");
app.UseDefaultFiles(options);
app.UseStaticFiles();
}
edited Jan 2 at 10:11
answered Jan 2 at 8:11
Manoj ChoudhariManoj Choudhari
2,2871721
2,2871721
Actually it is not going to the Microsoft login page as the new template has been changed. Previously we use to have index.cshtml. But now there is no view available in new templates. I think as per new template we need to write authentication on client side only. Waiting for your reply
– vikas biradar
Jan 2 at 9:54
I hope you have used app.UseDefaultFiles() in the startup configure method. This method looks for page with name "Default" or "Index" if no page is specified. But if you dont have pages with these names then you need to tell this method which should be default page. Edited my original answer to provide answer.
– Manoj Choudhari
Jan 2 at 9:57
Thank you manoj for reply. But the issue is authenticating to login.microsoftonline.com in startup.cs file. Previously it was working with home controller and index.cdshtml. But now the new template does not have view folder. instead of which we haves pages folder.
– vikas biradar
Jan 2 at 10:14
can you check in fiddler on what is happening ? You can check request is failing to reach your web server OR it is failing when trying to reach Azure AD url (login.microsoftonline.com). That would help you to confirm the exact issue.
– Manoj Choudhari
Jan 2 at 10:17
add a comment |
Actually it is not going to the Microsoft login page as the new template has been changed. Previously we use to have index.cshtml. But now there is no view available in new templates. I think as per new template we need to write authentication on client side only. Waiting for your reply
– vikas biradar
Jan 2 at 9:54
I hope you have used app.UseDefaultFiles() in the startup configure method. This method looks for page with name "Default" or "Index" if no page is specified. But if you dont have pages with these names then you need to tell this method which should be default page. Edited my original answer to provide answer.
– Manoj Choudhari
Jan 2 at 9:57
Thank you manoj for reply. But the issue is authenticating to login.microsoftonline.com in startup.cs file. Previously it was working with home controller and index.cdshtml. But now the new template does not have view folder. instead of which we haves pages folder.
– vikas biradar
Jan 2 at 10:14
can you check in fiddler on what is happening ? You can check request is failing to reach your web server OR it is failing when trying to reach Azure AD url (login.microsoftonline.com). That would help you to confirm the exact issue.
– Manoj Choudhari
Jan 2 at 10:17
Actually it is not going to the Microsoft login page as the new template has been changed. Previously we use to have index.cshtml. But now there is no view available in new templates. I think as per new template we need to write authentication on client side only. Waiting for your reply
– vikas biradar
Jan 2 at 9:54
Actually it is not going to the Microsoft login page as the new template has been changed. Previously we use to have index.cshtml. But now there is no view available in new templates. I think as per new template we need to write authentication on client side only. Waiting for your reply
– vikas biradar
Jan 2 at 9:54
I hope you have used app.UseDefaultFiles() in the startup configure method. This method looks for page with name "Default" or "Index" if no page is specified. But if you dont have pages with these names then you need to tell this method which should be default page. Edited my original answer to provide answer.
– Manoj Choudhari
Jan 2 at 9:57
I hope you have used app.UseDefaultFiles() in the startup configure method. This method looks for page with name "Default" or "Index" if no page is specified. But if you dont have pages with these names then you need to tell this method which should be default page. Edited my original answer to provide answer.
– Manoj Choudhari
Jan 2 at 9:57
Thank you manoj for reply. But the issue is authenticating to login.microsoftonline.com in startup.cs file. Previously it was working with home controller and index.cdshtml. But now the new template does not have view folder. instead of which we haves pages folder.
– vikas biradar
Jan 2 at 10:14
Thank you manoj for reply. But the issue is authenticating to login.microsoftonline.com in startup.cs file. Previously it was working with home controller and index.cdshtml. But now the new template does not have view folder. instead of which we haves pages folder.
– vikas biradar
Jan 2 at 10:14
can you check in fiddler on what is happening ? You can check request is failing to reach your web server OR it is failing when trying to reach Azure AD url (login.microsoftonline.com). That would help you to confirm the exact issue.
– Manoj Choudhari
Jan 2 at 10:17
can you check in fiddler on what is happening ? You can check request is failing to reach your web server OR it is failing when trying to reach Azure AD url (login.microsoftonline.com). That would help you to confirm the exact issue.
– Manoj Choudhari
Jan 2 at 10:17
add a comment |
I faced the exact same problem migrating my app from angular 5/.Net Core 2.0 to angular 7/.Net Core 2.2 and i found a way to keep the authentication server side.
The solution for that is to add a middleware that check if every request is authenticated and if it's not the case, force it.
app.Use(async (context, next) =>
{
if (!context.User.Identity.IsAuthenticated)
{
await context.ChallengeAsync();
}
else
{
await next();
}
});
add a comment |
I faced the exact same problem migrating my app from angular 5/.Net Core 2.0 to angular 7/.Net Core 2.2 and i found a way to keep the authentication server side.
The solution for that is to add a middleware that check if every request is authenticated and if it's not the case, force it.
app.Use(async (context, next) =>
{
if (!context.User.Identity.IsAuthenticated)
{
await context.ChallengeAsync();
}
else
{
await next();
}
});
add a comment |
I faced the exact same problem migrating my app from angular 5/.Net Core 2.0 to angular 7/.Net Core 2.2 and i found a way to keep the authentication server side.
The solution for that is to add a middleware that check if every request is authenticated and if it's not the case, force it.
app.Use(async (context, next) =>
{
if (!context.User.Identity.IsAuthenticated)
{
await context.ChallengeAsync();
}
else
{
await next();
}
});
I faced the exact same problem migrating my app from angular 5/.Net Core 2.0 to angular 7/.Net Core 2.2 and i found a way to keep the authentication server side.
The solution for that is to add a middleware that check if every request is authenticated and if it's not the case, force it.
app.Use(async (context, next) =>
{
if (!context.User.Identity.IsAuthenticated)
{
await context.ChallengeAsync();
}
else
{
await next();
}
});
answered Jan 31 at 15:38
homega52homega52
7315
7315
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54002724%2fazure-ad-authentication-not-working-for-new-asp-net-core-2-1-with-angular-5-2-ne%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hi vikas ! I'm also facing the same problem migrating my app to this new project template where there is no more cshtml file...Did you solve your problem ?
– homega52
Jan 31 at 10:58
Yes i have solved the problem. What problem you are facing?
– vikas biradar
Feb 1 at 5:23
I posted my solution. Did you use the same method ?
– homega52
Feb 1 at 14:05