I am upgrading a Web project from Windows XP / Visual Studio 2010 to Windows 8.1 and Visual Studio 2013. When I do this I get a migration report showing two warnings and 15 other messages, none of which appear to be of any consequence. I then adjust the target framework for the web project to 4.5.1 and run the project.
This displays the web page as I expect, but any interaction with it (selecting a new item on a pull-down, for instance) results in the error:-
HTTP Error 405.0 - Method Not Allowed
The page you are looking for
cannot be displayed because an invalid method (HTTP verb) is being
used.
Attempting to discover the reason for this, I find all the source code (.aspx files, .cs files, .config files and .css files) are all missing. Fortunately I can recover them from the backups that the migration process made, but this is still rather alarming. Can anyone tell me how to prevent this? What project setting might be responsible?
Edit I have tried copying the code back into the project directory after displaying the web page for the first time. Selecting a new item on the pull-down then works, but deletes the source code again. So the HTTP error appears to be a consequence of the page being actually missing during the post-back.
The page you are looking for cannot be displayed because an invalid
method (HTTP verb) is being used.
Cause 1
This problem occurs because the client makes an HTTP request by using an HTTP method that does not comply with the HTTP specifications.
Resolution :
Make sure that the client sends a request that contains a valid HTTP method. To do this, follow these steps:
Click Start, type Notepad in the Start Search box, right-click Notepad, and then click Run as administrator.
Note If you are prompted for an administrator password or for a confirmation, type the password, or provide confirmation.
On the File menu, click Open. In the File name box, type %windir%\system32\inetsrv\config\applicationhost.config, and then click Open.
In the ApplicationHost.config file, locate the tag.
Make sure that all the handlers use valid HTTP methods.
Save the ApplicationHost.config file.
Cause 2 :
This problem occurs because a client makes an HTTP request by sending the POST method to a page that is configured to be handled by the StaticFile handler. For example, a client sends the POST method to a static HTML page. However, pages that are configured for the StaticFile handler do not support the POST method.
Resolution :
Send the POST request to a page that is configured to be handled by a handler other than the StaticFile handler (for example, the ASPClassic handler). Or, change the request that is being handled by the StaticFile handler so that it is a GET request instead of a POST request.
Reference
The program when it runs uses old scratch files; when it starts up it deletes them; it determines these by deleting all files of the form:-
HttpContext.Current.User.Identity.Name + "*.*";
which at one time deleted all the files intended. On the new Windows 8 machine, the HttpContext.Current.User.Identity.Name resolves to the null string, with the inevitable consequences...
Please excuse me while I curl up with embarrassment.
Related
We got the following problem:
I am currently developing a web server implementing a specific API. The association behind that API provided specific test cases I'm using to test my implementation.
One of the test cases is:
5.3.2.12 Robustness, large resource ID
This test confirms correct error handling when sending a HTTP request with a very long location ID as URL parameter.
The url its calling looks something like this:
https://localhost:443/api/v2/functions/be13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005ebe13789-1f1e-47d0-8f8a-000000000005
Basically the tests checks, if my server responds with the correct error code if the URL is too long. (At the time of writing it is testing for Errorcode 405, but I already asked them if it shouldn't be 414)
I'm developing the server in Asp.Net 6 and it always returns Bad Request 400 in the testcase.
I don't seem to find a place to change the handling for this behaviour and I am not even sure, if I can, or if the IIS is blocking the request even before it reaches my server. I activated logging in IIS, but the request does not show in the logfile in inetpub/logs/LogFiles.
My question would be, if it is possible to tell IIS to return a different error code in this case, or if it is even possible to handle the error in my application.
What I tried:
Activating IIS Logs to see if the request is even passed to my site. (It did not)
Tried adding Filters to my Controller to see if I can catch an Exception
Checked, if Development Error Sites are called.
Breakpoints in existing middlewares are not reached.
EDIT:
I am now pretty sure now, that the request never reaches my application.
It is possible to reproduce the error by using the default site the IIS generates on windows. Just copy the whole path from above into a browser with the host http://localhost will also just produce the error 400
EDIT 2:
As #YurongDai pointed out, I tried activating failed request tracing for my IIS Site. I used the default path \logs\FailedReqLogFiles.
The folder was created, but no file is written, when I'm opening the URL above in my browser.
IIS Error 400 occurs when the server is unable to process a request sent to a web server. The most common cause of Bad Request error 400 is an invalid URL, but it can happen for other reasons as well. To resolve IIS Error 400, first make sure that you have entered the URL correctly, typos or disallowed characters in the URL are the most common causes of Bad Request errors. If the error persists after verifying the URL, please clear your browser's cache, DNS cache, and cookies and try again.
Clear your browser's cookies.
Clear your browser's cache.
Clear your DNS cache.(Execute the following command in the command prompt window: ipconfig /flushdns)
I have developed an App Service backend hosted on Azure using ASP.NET Core 2.2.
From time to time I'm getting a 500 status but I'm not able to find out where is that 500 being generated.
I'm using application Insights and I see on Failed Requests that sometimes there are some calls to my App Service which are returning 500.
If I reproduce that same call with same values with Postman I'm not getting any 500. There are also some End Client Apps making requests to this backend. I believe it's happening to them but why I can't reproduce the same result if I'm performing the same request with same values.
I know that 500 implies "Internal Server Error" and that it is related to the Application code but I've even configured my App Service to use a Global Error handling but I never get that 500 when I'm executing the same request that I see on Application Insights.
I have set on my Configure on StartUpp class the global error handling (just to show you that I have also enabled that)
app.UseExceptionHandler(config => ExceptionHandlingSettings.ConfigureGlobalExcpetionHandling(config));
I would like to know where or how to get more information in order to find out the code generating the error/exception because I guess there is some bug in my code which throws an unhandled exception.
Here are couple of steps which you can do to understand the root cause:
1- Change stdoutLogEnabled="false" to true and then check the logs at stdoutLogFile=".\logs\stdout". The error(s) there might tell you something.
The ASP.NET Core Module stdout log often records useful error messages not found in the Application Event Log. To enable and view stdout logs:
Navigate to the Diagnose and solve problems blade in the Azure portal.
Under SELECT PROBLEM CATEGORY, select the Web App Down button.
Under Suggested Solutions > Enable Stdout Log Redirection, select the button to Open Kudu Console to edit Web.Config.
In the Kudu Diagnostic Console, open the folders to the path site > wwwroot. Scroll down to reveal the web.config file at the bottom of the list.
Click the pencil icon next to the web.config file.
Set stdoutLogEnabled to true and change the stdoutLogFile path to: \?\%home%\LogFiles\stdout.
Select Save to save the updated web.config file.
Make a request to the app.
Return to the Azure portal. Select the Advanced Tools blade in the DEVELOPMENT TOOLS area. Select the Go→ button. The Kudu console opens in a new browser tab or window.
Using the navigation bar at the top of the page, open Debug console and select CMD.
Select the LogFiles folder.
Inspect the Modified column and select the pencil icon to edit the stdout log with the latest modification date.
When the log file opens, the error is displayed.
Please make sure to remove the logging once the inspection is completed.
2 - Use Middleware for handling erroneous request like app.UseDeveloperExceptionPage();
3- You can add application Insight in your app and try to put Info logging to understand what part of your code is causing the failure.
For additional reference, please check below doc:
https://learn.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-3.0
https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-exceptions
Hope it helps.
Using the C#/.NET Google+ sign-in quick start project, I'm hitting problems with IIS6. Here are the steps I followed:
downloaded the project from Github
modified the index.html and signin.ashx files to contain my Client ID and Client Secret
running the project on my machine (using the built in web server for Visual Studio 2010) works fine
published to Windows 2003 server with IIS6
added "index.html" as a default document for the web site
set the web site to use an app pool configured for the 4.0 .NET framework
attempted to access the page from Chrome
Accessing the site with no page specified on the URL (https://myserver.com/gplussample/) brings up the Google+ signin button. This works great and I'm taken to the page with my profile photo, circles, etc.
However, when I click the "disconnect" button, nothing happens. Using Chrome DevTools to examine the process, I see this error:
POST https://myserver.com/gplussample//disconnect 404 (Not Found)
The problem is the //disconnect - there's no page name (I believe it should be signin.ashx, as that's what works when I'm running the app on the dev web server with Visual Studio 2010).
I then attempted to access the site with a page name specified:
https://myserver.com/gplussample/signin.ashx
That results in a blank page and again, looking at the Chrome DevTools, I see a 400 Bad Request error for the .ashx handler. I searched and searched for solutions for .ashx handlers and "bad request" errors, with no success in this particular case.
Thinking IIS6 was the culprit, I published the site to an IIS7 instance.
With no page name specified on the URL (http://localhost/gplusoriginal/), I encountered the same error with the "disconnect" button - no action and a 404 error.
When I changed the URL to http://localhost/gplusoriginal/signin.ashx, I received this error:
Could not create type 'GPlus_ServerSideFlow.Signin'.
Again, back to Google and checking on .ashx handlers and issues with IIS7. I found a post about the web.config and specifying the handler there, so I tried that.
<system.webServer>
<handlers>
<add name="GPlus_ServerSideFlow.Signin" path="*.ashx" verb="*"
type="GPlus_ServerSideFlow.Signin" resourceType="Unspecified" />
</handlers>
</system.webServer>
Adding this snippet to the web.config resolved the "could not create type" error, but resulted in another 400 Bad Request error.
So, my questions are: What has to be done with II6 or IIS7 to get this sample project working? Are there additional steps in configuring IIS that need to be completed? Or something missing from the project code?
Thank you
The way that the sample works is that the RESTful endpoints are intercepted by an ashx handler, signin.ashx.cs. The handler can't be directly addressed so routes are setup in global.ashx.cs to map endpoints (/, /connect, /disconnect, etc) to that route handler.
As the sample ships, it assumes the built-in web server running on the root port. When moving to IIS, you need to change the path matchers from Equals to EndsWith in order to match the virtual directory you are deploying to:
// Redirect base path to signin.
if (context.Request.Path.EndsWith("/"))
{
context.Response.RedirectPermanent("signin.ashx");
}
// This is reached when the root document is passed. Return HTML
// using index.html as a template.
if (context.Request.Path.EndsWith("/signin.ashx"))
{
Apologies for the delay on this... but hopefully that fixes it! This fork of the C# starter has the changes in it, tested with IIS, and this update may end up getting merged back into the official sample soon.
I am having a problem when trying to convert an ASP .Net page to PDF using SautinSoft.PdfVision.
Using this library is quite straight forward, all you need to do is tho provide the URL of the page you want to convert and the PDF destination path.
SautinSoft.PdfVision v = new SautinSoft.PdfVision();
v.ConvertHtmlFileToPDFFile(url, pdfFilePath);
Instead of having the page I ask for to be rendered as PDF, I always get the one saying "Navigation to the webpage was canceled", as if IIS (version 7.5.7600.16385) was redirecting systematically my request.
In my development environment (Visual Studio Express 2012 for web, version 11.0.50727.1 RTMREL), I do not have this problem at all. Visual studio uses its own local web server whose configuration is the one by default and it works like a charm.
I added some log in the Page_Load event of the page I want to convert and for sure in my prod environment, this event is never triggered since I don't get any logs meaning the page never gets loaded. In my dev environment, my log does confirm that the pages is being loaded.
I have read a lot about this "Navigation webpage canceled" problem but all the answers I could find were about client side configuration, trust level in IE. I am using Chrome and its settings are the same whether I am debugging or hitting the prod server.
So my intuition really tells me something is going wrong on the server side.
So does anyone of you know about some IIS configuration that could fix my problem?
Thanks for your help.
I also faced similar kind of issues when using sautinsoft PDFVision
Solution:
in iis select your websites---> go to ssl settings --> client certificate --> ignore
this works for me
other chances if above not work:
goto application pool --> advanced settings---> loaduserprofile=true
I have a redirect on global.asax application_error function. When i'm debugging, every exception is treated by the function. When i am running application on web server, appears the error default page of the IIS. I have IIS7 and Visual Studio 2005.
Best regards!
IIS actually also has a fourth type of error page it can show. This page will be returned when you configure HTTP Errors to use a custom error page and a problem occurs when IIS tries to render it.
When IIS received a request for a given page in the demo application, it passes it to the ASP.NET runtime to be handled. The runtime generates a response which IIS then examines. IIS will potentially take action and replace this response if the response has an HTTP status code that is an error status code.
- If existingResponse is set to PassThrough, IIS takes no action and
the response is returned unaltered.
- If existingResponse is set to
Replace, IIS replaces the response with its own, according to the
value of the errorMode attribute so it will either replace it with a
detailed, a basic, or a custom error page.
- If existingResponse is set
to Auto, IIS replaces the response generated by ASP.NET with its own,
unless something called the SetStatus flag is set. (I will discuss
that flag later in this post.)
http://perspectivespace.com/error-handling-in-aspnet-mvc-3-part-2-custom