I have what seems to be the exact opposite of everyone else's problem! I am hosting a .Net4 site on IIS6, and while I want IIS to handle 404 errors (where I can configure it to send the error to an aspx page), it seems like .Net4 gets in the way by issuing a 302 redirect for the default page (which doesn't exist either) before I can get on with handling the 404 properly.
Basically, if I goto http://mysite/testProduct, .net4 issues a 302 for http://mysite/testProduct/default.aspx, which then goes on and gets handled by my error handling setup in IIS6 which is to redirect 404s to /404.aspx, which detects the product name, looks up an ID and does a Server.Transfer.
How can I stop .Net getting in the way? It's doubling the overhead of a page request, and will cause my products to get indexed with /default.aspx after them which I do not want.
AHA, Ben
EDIT: if I turn off CustomErrors in the web.config, .Net is still handling the error and not letting it pass to IIS at all - I see a 404 error page that is generated by .Net. So I get a 302 then a 404...!
Found the problem in the end - this was for an implementation of nopCommerce, which comes with UrlReWriter installed out of the box - it was this component that was causing the behaviour noted above...
Related
I have a website that implemented with .net core 2.1 and angular js.
I published this website on windows server that worked with IIS.
The problem is that, sometimes response of http requests for some files or request (the ajax request that called) is 404 error and sometimes it works correctly and I am sure that file is exists because if the user that faced with error, refresh the page, it will load correctly !
I attached a photos that compare same requests.
After many days I have this problem yet. I enabled IIS logs and attach one of xml log file here.
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);
I'm using mvc4 and .Net 4.5 in my project with SSL. Now, on localhost and even on server, the login page gets redirect a bunch of times and then loads without and css on page. In browser debugger I get error as:
Uncaught SyntaxError: Unexpected token <http://localhost:55248/Account/Login? ReturnUrl=%2fbundles%2fjqueryval%3fv%3dWrBNyT_GYLXAZ7iWD7vDdFccq24m7v_9MPi3rcQ8FO01&v=WrBNyT_GYLXAZ7iWD7vDdFccq24m7v_9MPi3rcQ8FO01...
I'm using bundling and code snippet as below.
bundles.Add(new ScriptBundle("~/bundles/BaseJs")
.Include("~/Scripts/jquery-{version}.js")
.Include("~/Scripts/jqueryui/jquery-ui.js")
.Include("~/Scripts/bootstrap.js"));
The syntax error is from the error page being loaded as JavaScript (when it's obviously not JavaScript). It's a red herring. The true problem is that your JavaScript file is needing authorization in the first place.
Typically, this wouldn't be an issue. By default, anything with an extension (.js, for example) is ignored by MVC and handled directly by IIS. Worst case scenario, there, IIS doesn't have permission to read the file, and you end up with a 403 Forbidden. It would end there, as an IIS-level 403 would not trigger a login page redirect, mostly because, again, MVC is not involved.
However, if you've bungled around the with default setup, such that MVC is now handling all requests, even for static files. Then, the action that's being triggered to handle the request to your JavaScript file is requiring authorization, and therefore is redirecting to the login page. So find out what action is being hit and either remove the requirement for it to be authorized or have the right action serve the file. Or, ideally, leave things as they should be and let IIS do what IIS does best and serve the static files.
EDIT
I wasn't paying attention to the fact that bundles are rendered without a file extension. However, the steps to correct the issue are largely the same. Something is mostly likely off with your routing, and the request for the bundle is actually being caught by one of your actions, particularly one that requires authorization. Look out for catch-all routes and make sure that you're not using a route like "bundles" anywhere in your RouteConfig.cs or any of your Route attributes, if you're using attribute routing.
First try to include your bundles like that :
.Include( "~/Scripts/jquery-{version}.js",
"~/Scripts/jqueryui/jquery-ui.js",
"~/Scripts/bootstrap.js"
);
Include takes string[] as parameter and you don't need to call include for each row. Then you should debug your bundles to see which js is giving the error.
Try to comment out rows 1 by 1 to see what would be the result. The problem is definatelly in your bundles, I also had these kind of errors. If you can provide more code - > snippet from the view, of the css loading and bundles and stuff like that I would be able to help you more.
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.
This could be a entirely hosting service related problem but I'll post it here in case it is a more common problem.
I'm running a OData service on my ASP.NET MVC 2 site which works fine on my laptop IIS but when I deploy it to my site at Winhost I get 404 Resource not found error when trying to access the .svc-file.
Earlier I had 2 different authentications on so I got the "System.InvalidOperationException: IIS specified authentication schemes 'Basic, Anonymous'...." error so I know that at that point the handler was trying to start the service.
After fixing that, I got the "Resource not found error".
The service is in /Services folder but it does not seem to matter. No matter where I put it it always gives me the 404 error. All the binaries from my local sites bin folder are in my remote sites bin folder.
Everything else on the site seems to be working fine.
If anyone has a solution to this, help would be much appreciated.
Finally got this figured out. Since my site is an ASP.NET MVC 2 site I need to ignore the route to the service. Otherwise ASP.NET will start looking for a controller for that URI.
So I added routes.IgnoreRoute("Services/ServiceFilename.svc/{*pathInfo}"); to my global.asax.cs and voilá problem solved.
Although I don't quite understand why the service works on my laptops IIS 7 without the ignored route.