Bug or misconfigured? ASP.NET Core 2.1 firing 404 error on Access Denied - authentication

I am not sure if I found a bug, or if I just messed up the configuration some how.
I have an ASP.NET Core 2.1 Razor website using AzureADB2C authentication, utilizing the new 'pre-packaged' configuration utilities). When I try to access a page that my test user doesn't have access to, it returns a generic 404 page instead of going to the pre-defined AccessDenied page.
Looking at the browser URL, it is trying to go to:
https://localhost:44310/Account/AccessDenied?ReturnUrl=%2FAbout
But I think it should be:
https://localhost:44310/AzureADB2C/Account/AccessDenied?ReturnUrl=%2FAbout
(Note: if I manually put this in the browser, it works correctly)
When, you sign out, it takes you to:
https://localhost:44310/AzureADB2C/Account/SignedOut
Does anyone know if there is a configuration to control this redirect? Or is this a bug in the new 2.1 Authentication modules? (And if so, any ideas how to work around it until it is fixed?)

I reported this to MSFT as a bug and they are looking into it. But I did figure out a workaround, in case anyone else is getting this same issue.
The issue on MSFT site is: https://developercommunity.visualstudio.com/content/problem/301357/microsoftaspnetcoreauthenticationazureadb2cui-acce.html
The workaround is to use the Rewrite Middleware to redirect the call. Putting the below into the Configure method of your Startup.cs class will handle the issue.
// Workaround for AccessDenied URL error in MSFT code
RewriteOptions rewrite = new RewriteOptions().AddRedirect("^Account/AccessDenied(.*)", "AzureADB2C/Account/AccessDenied$1");
app.UseRewriter(rewrite);

Related

Visual Studio Code only offers Weather Forecast proxy

I am not able to run any other controller in the default React app for .NET Core 6.0. Has anyone figured this out? I believe I saw a quick message on the terminal about the weatherforecast route being in the SPA proxy.
Whenever I try to go to any other route for a controller it redirects to the fallback page. I have routing setup with default settings. Just seems an odd behavior.
It's obviously a proxy issue because if I run the controller from the IIS port 7132 instead of the 44402 (spa server), I am able to retrieve the json response. There's quite a long readme file in here I can plod through but maybe someone has a better solution.
Update: I found the solution, well there were several, from setting CORS policies on the server side, etc. The easiest way was to do it "pre-flight". I found a handy file called setupProxy.js (who knew lol), where I was able to set an array of end points to proxy. And this had the /weatherforecast endpoint already specified. So now it all works! I guess I answered my own question.
const context = [
"/weatherforecast","/account"
];

TYPO3 10.4.21 Pages accessible only via their id

Following a migration, I am trying to reconfigure TYPO3.
The backend is accessible by its url and I manage to connect. But the home page for example gives me the following error: The page did not exist or was inaccessible. Reason: No site configuration found.
All pages are not accessible by their url normally but are accessible through different query parameters, like /index.php?id=2&L=0.
I already tried to replace the .htaccess with the basic one provided by TYPO3, I also checked the Apache configuration and everything seems to be ok. I am not familiar with the TYPO3 CMS so I don't know if some of these configurations are done directly in its files. To me, it seems to be a mod_rewrite problem but I can't find it.
Someone would have a solution or at least a track to solve this problem?
As stated in the error message that you've posted it seems that the site configuration is missing. In the TYPO3 backend you can create new site configuration via Site Management => Sites.
Please check the site handling documentation for details.

Dots in URL causes 404 with Web API call in .net core

I have a similar requirement which is mentioned in the link Dots in URL causes 404 with ASP.NET mvc and IIS . Our requirement is, we also do have URLs with dots in the path. For example I may have a URL such as www.example.com/people/michael.phelps (This example is taken from above link)
URLs with the dot generate a 404. If we pass without the dot, then everything works. If we add the dot I get a 404 error.
The above link provide solution for earlier versions of .net where we can have webconfig files. But we are using .net core to build web API application. Dotnet core does not support webconfig files. Can someone please suggest how can we arrive at the solution by using .net core.
Late answer but we had a similar case:
We had a url looking like https:/domain.com/somepath/smoething.cd
This returned a 404 from the IIS. Adding a / at the end of the url behind the .cd fixed the issue.
Strange but notable: not all.something return a 404, .com at the end of the path for example works

Catching HTTP errors before redirect via 51degrees (vb.net)

I am using 51degrees.mobi and it is working well but in the case of the mobile server experiencing issues (HTTP error status) I want to be able to allow the user to continue on with the desktop version of the mobile site. I know I can stop the redirect by commenting out the redirect section of the config but is it possible to stop the redirect pragmatically?
I am currently working for 51Degrees.mobi.
If I understand you correctly then what you are asking to do is not possible through 51Degrees as you cannot change the configuration rules.
However what you want to do may be possible by editing your web.config file so that it will send you to the normal page if an error code is thrown using a customErrors element? More information on doing that can be found here. It may also be possible to do by modifying your pages PreInit() event.
Hope this helps.

Sitefinity 4.4 and Extensionless URLS: Is the sf404.aspx error mapping still required

Does anyone know if you still need the sf404.aspx mapping for Sitefinity 4.4?
I'm trying to run a new test SF 4.4 project, but when I try and login the page just gives me the following:
HTTP 404 cannot find /sf404.aspx (this was mapped like that for Sitefinity 3.7)
I then changed the IIS 404 configuration from sf404 to default and now I just get HTTP/1.1 404 Object Not Found.
The project works through Cassini, but not through IIS 6.
Any ideas?
Regards,
Jacques
the sf404.aspx page is definitely only used for Sitefinity 3.x and should not be mapped in a Sitefinty 4 website.
If you are attempting to run a newer version of Sitefinity on IIS6, you need to make sure to use a wildcard mapping so that all requests go through the ASP.NET engine.
This page details everything you need to setup to run Sitefinity on IIS6: http://www.sitefinity.com/documentation/documentationarticles/installation-and-administration-guide/install-sitefinity/configuring-the-iis-to-host-sitefinity-projects
You might also find this blog post helpful: http://www.sitefinity.com/blogs/joshmorales/posts/11-02-23/installing_sitefinity_4_on_iis_6.aspx