ashx handler DELETE request not working HTTP 405.0 - asp.net

I'm getting a HTTP Error 405.0 - Method Not Allowed error while trying to make a DELETE request to a .ashx handler from the jquery file uploader I was trying to implement.
Referencing this question (http://stackoverflow.com/questions/6695587/enabling-put-on-iis-7-5-for-an-ashx-handler-using-windows-authentication) I've added the below section to my web.config file, but can't seem to get the error to go away. Are there any other tricks I'm not finding to get DELETE to work?
I'm using .Net 4.0 and IIS7.5 with the windows azure storage emulator running also.
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers accessPolicy="Read, Write, Execute, Script">
<remove name="WebDAV" />
<remove name="SimpleHandlerFactory-Integrated-4.0" />
<remove name="SimpleHandlerFactory-Integrated" />
<add name="SimpleHandlerFactory-Integrated" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Write" preCondition="integratedMode" />
<add name="SimpleHandlerFactory-Integrated-4.0" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Write" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="*" verbs="GET,HEAD,POST,PUT,DELETE,DEBUG" />
</authorization>
</security>
</system.webServer>
And here's the front end code calling the handler:
<td class="delete">
<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" data-url="/webservices/FileTransferHandler.ashx?f=df69bfd1-2a15-43e3-9310-3ca163e2aeb2" data-type="DELETE" role="button" aria-disabled="false" title="Delete">
<span class="ui-button-icon-primary ui-icon ui-icon-trash"></span>
<span class="ui-button-text">Delete</span>
</button>
</td>
I've enabled failed request tracing and it's trying to use the staticFileModule while based on the requests extension of .ashx I'd think it would try to use the SimpleHandlerFactory.
Here's the link I'm hitting: http://local.testsite.com:80/webservices/FileTransferHandler.ashx?f=df69bf1-2a15-43e3-9310-3ca163e2aeb2
Why would that link be using the staticFileModule, isn't that for images or documents like .jpg and .pdf?

Here's the final web.config section. The thing I needed to add I was missing was changing the staticFileHandler from using "all verbs" to all of them spelled out.
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers accessPolicy="Read, Write, Execute, Script">
<remove name="StaticFile" />
<remove name="SimpleHandlerFactory-ISAPI-2.0" />
<remove name="WebDAV" />
<remove name="SimpleHandlerFactory-Integrated-4.0" />
<remove name="SimpleHandlerFactory-Integrated" />
<add name="SimpleHandlerFactory-Integrated" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Write" preCondition="integratedMode" />
<add name="SimpleHandlerFactory-Integrated-4.0" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Write" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="SimpleHandlerFactory-ISAPI-2.0" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
<add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
</handlers>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="*" verbs="GET,HEAD,POST,PUT,DELETE,DEBUG" />
</authorization>
</security>
<tracing>
<traceFailedRequests>
<remove path="*" />
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI" verbosity="Verbose" />
</traceAreas>
<failureDefinitions statusCodes="405" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>

If you are using PHP inside the IIS Server then follow these steps.
I have resolved the issues by adding delete verb for PHP Module.
1.Open IIS.
2.Go to configuration Editor.
3.Form Section DropDown Select System.WebServer.
4.Select Handler,It will show you the available handler click next to
count to open the handlers.
5.Goto PHP_viaFastCGI and Add Delete as verb next to POST.

Related

MVC Site Error while Hosting

I have below attached image file while trying to host my web site to internet. It has been developed by ASP.net mvc, and the webconfig.file like this;
{
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<customErrors mode="Off"></customErrors>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true"/>
</security>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<!--alt satırı ekledim-->
<remove name="UrlRoutingHandler"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<validation validateIntegratedModeConfiguration="false" />
<!--alt satırı ekledim-->
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
</system.webServer>
}
what can i do to finish hosting ?
I hope this issue occurs trusted level of the application. I am believing your web.configuration is missing trusted level configuration, For that, we can add few line as below code
you have to add the <trust level="Full"/> under the <system.web> the element in the web.config file. I hope these will help you.

ASP.NET deployment web service - could not load type namespace.application

After building the web service and publishing dll files under the bin folder and web.config file under the main directory to my hosting but it shows the following error:
cs:
namespace jsonwebservice
{
public class getvideos:IHttpHandler
{
...
web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<defaultDocument>
<files>
<clear/>
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="default.aspx" />
<add value="index.php" />
</files>
</defaultDocument>
<httpErrors errorMode="DetailedLocalOnly" existingResponse="Auto" />
<handlers>
<add name="getdata" path="getdata" verb="*" type="jsonwebservice.getvideos" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>

Connect via hostname or IP act different?

I have a web page on ISS 8.5 (Windows Server 2012 R2). Project name is KTS. Server name is MANKTS and it's IP is 10.3.11.165.
On an other computer, When I connect webpage like "http ://10.3.11.165/KTS/", everything is ok. But when I connect like "http ://MANKTS/KTS/" webpage behave an old webpage (internet explorer behave like IE7). And my webpage looking bad.
with host:
and wtih IP:
And the web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="Telerik.Skin" value="Windows7" />
<add key="Telerik.ScriptManager.TelerikCdn" value="Disabled" />
<add key="Telerik.StyleSheetManager.TelerikCdn" value="Disabled" />
</appSettings>
<connectionStrings>
<add name="SQL_ConnectionStr" connectionString="Data Source=***;Initial Catalog=KTS;User ID=***;Password=***" />
<add name="SQL_ConnectionStr_Kart" connectionString="data source=***;initial catalog=***;Password=***;persist security info=True;user id=***" />
</connectionStrings>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages controlRenderingCompatibilityVersion="4.5">
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
</controls>
</pages>
<httpHandlers>
<add path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" validate="false" />
<add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false" />
<add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false" />
<add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false" />
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
</httpHandlers>
<globalization culture="tr-TR" uiCulture="tr-TR" />
<customErrors mode="Off" />
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ChartImage_axd" />
<add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_SpellCheckHandler_axd" />
<add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_DialogHandler_aspx" />
<add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_RadUploadProgressHandler_ashx" />
<add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_WebResource_axd" />
<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>
How can I fix this?
This happens on intranet sites in IE because the Display intranet sites in Compatibility View setting is defaulted to on. Unfortunately all site users have to go to Tools -> Compatibility View Settings and uncheck Display intranet sites in Compatibility View.
I have no idea why MS decided to make this the default setting.

Custom error page for extension less urls

I have a DotNetNuke 7 website and I have enabled custom errors like so:
<customErrors mode="On" defaultRedirect="Error.aspx">
<error statusCode="404" redirect="FileNotFound.aspx" />
</customErrors>
I also want to add such errors for extension less URLs but when I try to add a wildcard mapping it breaks the site with 404 on the http://mysite.com etc
<add name="WILDCARDMAPPING" path="*" verb="*" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" allowPathInfo="false" preCondition="integratedMode,bitness64" />
How do I setup the handlers..
<handlers accessPolicy="Read, Execute, Script">
<remove name="WebServiceHandlerFactory-Integrated" />
<add name="LogoffHandler*" path="Logoff.aspx" verb="*" type="DotNetNuke.Services.Authentication.LogOffHandler, DotNetNuke" preCondition="integratedMode" />
<add name="RSSHandler" path="RSS.aspx" verb="*" type="DotNetNuke.Services.Syndication.RssHandler, DotNetNuke" preCondition="integratedMode" />
<add name="LinkClickHandler" path="LinkClick.aspx" verb="*" type="DotNetNuke.Services.FileSystem.FileServerHandler, DotNetNuke" preCondition="integratedMode" />
<add name="CaptchaHandler" path="*.captcha.aspx" verb="*" type="DotNetNuke.UI.WebControls.CaptchaHandler, DotNetNuke" preCondition="integratedMode" />
<add name="UserProfilePageHandler" path="User.aspx" verb="*" type="DotNetNuke.Services.UserProfile.UserProfilePageHandler, DotNetNuke" preCondition="integratedMode" />
<add name="RadProgressHandler" verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" preCondition="integratedMode" />
<add name="UserProfilePicHandler" path="ProfilePic.ashx" verb="*" type="DotNetNuke.Services.UserProfile.UserProfilePicHandler, DotNetNuke" preCondition="integratedMode" />
<remove name="ExtensionlessUrl-Integrated-4.0" />
<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="SitemapHandler" path="Sitemap.aspx" verb="*" type="DotNetNuke.Services.Sitemap.SitemapHandler, DotNetNuke" preCondition="integratedMode" />
<add name="ClientDependencyHandler" verb="*" path="DependencyHandler.axd" type="ClientDependency.Core.CompositeFiles.CompositeDependencyHandler, ClientDependency.Core" preCondition="integratedMode" />
<add name="Telerik.Web.UI.WebResource" verb="*" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" preCondition="integratedMode" />
<add name="Telerik.Web.UI.ChartHttpHandler" verb="*" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
<add name="HtmTemplateFileHandler" verb="*" path="*.htmtemplate" type="DotNetNuke.Providers.RadEditorProvider.HtmTemplateFileHandler, DotNetNuke.RadEditorProvider" preCondition="integratedMode" />
<add name="WILDCARDMAPPING" path="*" verb="*" type="" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" allowPathInfo="false" preCondition="integratedMode,bitness64" />
</handlers>
I have tried movie the WILDCARDMAPPING handler I added to the top, middle but it doesnt work.
DNN already provides support for extension less urls when there is a page that has been added to the CMS like /Home but shows the normal 404 error message for /somepage.
Just add to each directory an index.html that shows what you would like to display for that case - by default opening http://SomeUrl/some/path/ always opens/tries to open http://SomeUrl/some/path/index.html
This works:
<system.webServer>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/FileNotFound.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
DNN 7.1 includes the new "Advanced URL Provider" (based on iFinity's URL Master extension), which includes built-in support for 404 pages & extension-less URLs. There is a page called "404 Error Page" in a new DNN 7.1 site (you have to create it manually in an upgraded site, see the accepted answer at http://www.dnnsoftware.com/answers/cid/350985), which will be returned for pages that aren't found (whether there's an extension or not).
Related:
DNN 404 Handling article on DNN's wiki
Blog post on 404 handling

What causes a 404.4 on IIS 7.5 for delivering a static file?

I'm trying to set my default page to Index.html on an ASP.NET site running on IIS7.5. I keep getting a 404.4 which tells me that a handler is not set up. However, I have a <handler> and an <httpHandlers> value set up for my html pages. I've also specified the default document. Yet I keep getting a 404.4.
I CAN browse to myuri/index.html but I can't get it to load as the default.
Any suggestions?
Here's my web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings />
<connectionStrings />
<system.web>
<authentication mode="Windows" />
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0" />
<httpHandlers>
<add path="*.html" verb="*" type="System.Web.StaticFileHandler" />
<add path="~/assets/*" verb="*" type="System.Web.StaticFileHandler"/>
<add verb="*" path="*.rastahook" validate="false" type="OpenRasta.Hosting.AspNet.OpenRastaRewriterHandler, OpenRasta.Hosting.AspNet" />
</httpHandlers>
<httpModules>
<add name="OpenRasta" type="OpenRasta.Hosting.AspNet.OpenRastaModule, OpenRasta.Hosting.AspNet" />
</httpModules>
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID" />
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true" />
<defaultDocument enabled="true">
<files>
<clear />
<add value="/index.html" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Remove WWW" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="threetasks.apphb.net{PATH_INFO}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<httpCompression directory="%SystemDrive%\websites\_compressed" minFileSizeForComp="1024">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" />
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=Edge,chrome=1" />
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="OpenRasta" type="OpenRasta.Hosting.AspNet.OpenRastaModule, OpenRasta.Hosting.AspNet" />
</modules>
<handlers accessPolicy="Script,Read">
<clear />
<add name="StaticFile" path="index.html" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
<add name="StaticFiles" path="~/assets/*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
<add name="OpenRasta" verb="*" path="*.rastahook"
type="OpenRasta.Hosting.AspNet.OpenRastaRewriterHandler, OpenRasta.Hosting.AspNet" />
</handlers>
<staticContent>
<!-- Set expire headers to 30 days for static content-->
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
<remove fileExtension=".css" />
<mimeMap fileExtension=".css" mimeType="text/css; charset=UTF-8" />
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="text/javascript; charset=UTF-8" />
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json; charset=UTF-8" />
<remove fileExtension=".rss" />
<mimeMap fileExtension=".rss" mimeType="application/rss+xml; charset=UTF-8" />
<remove fileExtension=".html" />
<mimeMap fileExtension=".html" mimeType="text/html; charset=UTF-8" />
<remove fileExtension=".xml" />
<mimeMap fileExtension=".xml" mimeType="application/xml; charset=UTF-8" />
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
<mimeMap fileExtension=".ogg" mimeType="video/ogg" />
<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
<mimeMap fileExtension=".webm" mimeType="video/webm" />
<!--<mimeMap fileExtension=".svg" mimeType="images/svg+xml" />-->
<!--<mimeMap fileExtension=".svgz" mimeType="images/svg+xml" />-->
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
</staticContent>
</system.webServer>
</configuration>
For handling static content in iis 7.5, you need to register mime type via the following element in web.config file within element. I am mostly used for mp4 videos withot it 404.4 error arises.
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<!-- for html may be -->
<mimeMap fileExtension=".html" mimeType="text/html" />
</staticContent>
Taking a step back....where are you setting the default document?
If you set it in web.config, then you are saying that the ASP.Net runtime will/should handle .html extension. In other words, web.config pertains to ASP.Net.
Have you set the default document in IIS?
If its just a static file, there is no need for ASP.Net to even be involved - IIS should handle htm/html files out of the box.
What we ended up doing was splitting the project. Our goal was to have a service backend with a think JavaScript front end. Some of this is to try out different patterns and ideas we have. I'm writing the service and my friend is writing the front end. After talking about it, they don't need to be in the same project.
That is, I'll create an API and he'll create a client that can be hosted anywhere. With that in mind, my site will now just do API work, and will not need to deliver any html as a default page.

Resources