Intermittent "Request format is unrecognized for URL unexpectedly ending in" - c#

Intermittently we see on a server the error
Request format is unrecognized for URL unexpectedly ending in /methodname
All solutions I have found for this error gives the same answer, which is what is answered in i.e. this question: Request format is unrecognized for URL unexpectedly ending in
The big problem for me here is that my web.config file already includes the necessary info:
<system.web>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
</system.web>
And it obviously works as the webservice can be called just fine, until it suddenly fails for no apparent reason.
Restarting the webservice (by forcing a web.config change) or even restarting the computer always brings the service back up, until it fails again a day or two later.
What can cause this error, appart from the HttpGet/HttpPost settings?

Related

IIS Changing Error Page Responses

I have an MVC application that is running on IIS. I have created a custom exception filter handler that returns a custom JSON object. When I run it locally everything works correctly.
However, when I deploy it to IIS the correct HTTP Status Code is returned, but instead of getting my custom JSON object, I am getting a plain text response that says "Bad Request" or "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
In my web config, I have added:
<customErrors mode="Off" />
and
<httpErrors>
<clear />
</httpErrors>
Any suggestions would be greatly appreciated.
Thanks!
I found the solution. I needed to add errorMode = "Detailed to my httpErrors tag.
<httpErrors errorMode="Detailed">
<clear />
</httpErrors>

How can I get a custom error page for trace.axd in MVC3?

My MVC3 application displays custom error pages for 403, 404, and 500 status codes, but browsing to trace.axd displays the following YSOD:
Server Error in '/' Application.
Trace Error
Description: Trace.axd is not enabled in the configuration file for this application. Note: Trace is never enabled when <deployment retail=true />
Details: To enable trace.axd, please create a <trace> tag within the configuration file located in the root directory of the current web application. This <trace> tag should then have its "enabled" attribute set to "true".
<configuration>
<system.web>
<trace enabled="true"/>
</system.web>
</configuration>
So I have trace disabled, which is good, but why is the 500 page not being displayed, since this it's a 403 being returned from the server? I'd be happy enough with a 404, 403, or 500 really - just as long as it's not an ugly yellow screen!
Edit: I was getting a 500 along with the YSOD when running on localhost, but it's actually a 403 on the server which is closer to what I was expecting - but still no custom error page. It's also a slightly different standard error page on the server:
Server Error in '/' Application.
Trace Error
Description: The current trace settings prevent trace.axd from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable trace.axd to be viewable on remote machines, please create a <trace> tag within the configuration file located in the root directory of the current web application. This <trace> tag should then have its "localOnly" attribute set to "false".
<configuration>
<system.web>
<trace localOnly="false"/>
</system.web>
</configuration>
Removing the IgnoreRoute as suggested by #Cosmologinaut didn't work for me and as he says feels wrong. I found a better solution which is to remove the tracing HTTP handler in the Web.config file:
<system.webServer>
<!-- remove TraceHandler-Integrated - Remove the tracing handlers so that navigating to /trace.axd gives us a
404 Not Found instead of 500 Internal Server Error. -->
<handlers>
<remove name="TraceHandler-Integrated" />
<remove name="TraceHandler-Integrated-4.0" />
</handlers>
</system.webServer>
Navigating to /trace.axd now gives us a 404 Not Found instead of 500 Internal Server Error.
Since there were no responses I asked #shanselman on Twitter, who suggested <deployment retail = "true" /> might solve it, but it still returned the same YSOD.
In the end I solved it by removing routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); from the routing config. Doesn't quite seem right, but it works.

Can't access /elmah on production server with Elmah MVC?

I installed the elmah.mvc nuget package and kept the default configuration of that sans setting up sending an email and plugging it into a SQL database.
On my local machine when I use the Visual Studio host, I can open my app and access /elmah fine to see a report of the errors. However, when I try and access /elmah on production, I get two errors, first I get a 403 access is denied server error. Then in my email (from elmah) I get:
System.Web.HttpException: Server cannot set status after HTTP headers have been sent.
Anyone know what is going on here and how to fix? Thanks.
I tried the following so far as suggested by the answers below:
In <system.webServer>
<handlers>
<add name="elmah" verb="GET" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
</handlers>
And in <system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
I tried setting the path to both elmah.axd and simply ~/elmah. All still give the same error, and still works locally, but not in production.
Edit: It actually also works when I remote into the server and access it via browser on there (not using localhost, but the actual site address). So what permission am I not having? Seems like it's at the server level.
You need to enable Elmah for remote access by adding the following configuration setting to the <elmah> section in your web.config file. The default setting for this value is false, which only allows localhost, hence why it is working on your local machine from within Visual Studio.
<elmah>
<security allowRemoteAccess="true"/>
</elmah>
I always seem to forget this myself and spend a few minutes scratching my head ;)
Make sure you HttpHandler is defined in the webServer section in your web.config file.
<system.webServer>
<httpHandlers>
<add name="elmah" verb="GET" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
</httpHandlers>
</system.webServer>

how to deal with this "unrecognized for URL..." problem?

This is link which is explaining in detail, the problem i am facing right now.
I am getting a frequent exception whenever a call made to my web services. It returns appropriate results but still complaining about URL format.:-
Request format is unrecognized for URL
unexpectedly ending in
/WebServiceMethod
So what do you suggest guys?
Thanks.
There is quite a common issue that causes this error, that can easily be fixed by adding
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
...to web.config. Hopefully that fixes it for you.

Unable to access WebService

I have a webservice # http://recpushdata.cyndigo.com/Jobs.asmx but I'm not able to access it though I am adding it as a WebReference properly.
Any Help would be great.
AFAI can see, the asmx page has server errors, so you will not be able to access it.
Contact the admin of the web service to fix the errors.
Do you mean you are getting the "The test form is only available for requests from the local machine." error when accessing a method?
If so, you need to add the following into your <system.web> part of your web.config
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
This enables you to access the method from the local machine

Categories