I have built a custom handler to threat requests of some specific files:
<add verb="*" path="*.pps,*.pdf,*.ppt,*.doc" type="CustomHandler"/>
Now, there is a folder, let's say: "/free/" where this handler should not be called. Is there a way to accomplish this?
Thanks a lot!
You can put a remove element inside a web.config in that folder.
<configuration>
<system.web>
<httpHandlers>
<remove verb="*" path="*.pps,*.pdf,*.ppt,*.doc"/>
</httpHandlers>
</system.web>
</configuration>
Related
Introduction
My ServiceStack service handles route parameters that often contain periods ie:
/people/search/b.j./upton. Initially, asp.net/ServiceStack would throw a "404 - Not Found" exception when it encountered this route. I tried encoding %2E the periods with no luck but eventually resolved the issue after seeing some related questions by setting the relaxedUrlToFileSystemMapping property (info) within my web.config.
Problem
This worked perfectly until today when I had to change my service location from the default path to a custom path by adding <location path="api"> (as described here) to my web.config. Since adding the location node in web.config the relaxedUrlToFileSystemMapping setting is no longer applied and my routes with periods /api/people/search/b.j./upton are breaking once again resulting in '404 - Not Found' exceptions from ServiceStack.
Setup
ServiceStack - v3.9.56
IIS 7.5 / IIS Express (happens on both)
web.config:
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
<httpRuntime relaxedUrlToFileSystemMapping="true"/>
...
</location>
Question
Anyone have an idea why the relaxedUrlToFileSystemMapping property is ignored when it is moved from the default path to within my custom <location path="api"> in web.config?
Thanks!
After some tinkering with my web.config I was able to resolve this by moving the relaxedUrlToFileSystemMapping entry into it's own node outside of the <location> node. I'm not sure if this is a recommended approach (multiple <system.web> entries?) or might cause some other conflict(s) but after running a full system test of the service everything is working fine again so I'm going with this for now.
My updated and complete web.config for reference:
<configuration>
<system.web>
<httpRuntime relaxedUrlToFileSystemMapping="true"/>
</system.web>
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<connectionStrings>
<add name="AppDb" connectionString="data source=AppHost\SQLEXPRESS;Initial Catalog=db;User Id=AppUser;password=AppPwd;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
</configuration>
Did you change the root path in the AppHost file
public override void Configure(Container container)
{
SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api" });
}
When I add this code to my aspx ,
<telerik:RadEditor ID="REWelcome" runat="server"
AutoResizeHeight="True" Width="500px" ToolbarMode="Floating">
<Content>
</Content>
<TrackChangesSettings CanAcceptTrackChanges="False"></TrackChangesSettings>
</telerik:RadEditor>
And I got this error message ,
'~/Telerik.Web.UI.WebResource.axd' is missing in web.config.
RadScriptManager requires a
HttpHandler registration in web.config.
How can I solve it ?
In your web.config - add the following to the system.web (omit the system.web, just used to show you level:
<system.web>
<httpHandlers>
<add verb="*" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false" />
<add verb="*" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4"></add>
<add verb="*" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4"></add>
</httpHandlers>
The bottom two are not needed gnerally but I am assuming you want the extended features of the editor, like dialogs and spellchecking.
I also add location at the same level as system.web
<location path="Telerik.Web.UI.WebResource.axd">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
You also have to add the Telerik.Web.UI.dll file in the bin folder of your application.
That worked for me.
These are the handlers needed for RadEditor and RadScriptManager:
<httpHandlers>
<add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false"/>
<add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false"/>
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false"/>
</httpHandlers>
and
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="Telerik_Web_UI_DialogHandler_aspx" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler"/>
<add name="Telerik_Web_UI_SpellCheckHandler_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler"/>
<add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource"/>
</handlers>
</system.webServer>
source: http://www.telerik.com/forums/telerik-web-ui-webresource-axd-is-missing-in-web-config-f25e27e5a5ac
if the error message is like this::
~/Telerik.Web.UI.WebResource.axd' is missing in web.config. RadScriptManager requires a HttpHandler registration in web.config. Please, use the control Smart Tag to add the handler automatically, or see the help for more information: Controls > RadScriptManager
Then you add the following into your web.config file:::
<httpRuntime targetFramework="4.5.2" />
<httpHandlers>
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
</httpHandlers>
I fixed it by changing the ASP Application pool from "Integrated" to "Classic" mode. All my configurations were correct, as described in other posts here. This is probably specific to my configuration, but may be worth trying.
I came across this issue while deploying to IIS 7.
You could set the Managed pipeline mode from Integrated to Classic. This indeed solves the problem with behaving IIS 7.5 as old 6.0 (with handler registered in old web.config node), but I wasn’t convinced that to use Telerik’s controls, I should use old type of pipeline.
Our old web.config file registered Telerik’s handler only in old section for IIS 6 (and that sufficed for cassini and IIS 6.0) and not in new section.
So I had to add this piece of xml to web.config :
<system.webServer>
<handlers>
<add name="Telerik.Web.UI.WebResource" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" />
</handlers>
</system.webServer>
There is a very detailed KB article on this matter including all possible reasons for the error and how to fix it. Please check it out at Error: Web.config registration missing! The Telerik dialogs require a HttpHandler registration in the web.config file.
One of the best solutions is to open the web.config file and replace Telerik.Web.UI.DialogHandler.aspx with Telerik.Web.UI.DialogHandler.axd
<system.web>
<httpHandlers>
<add path="Telerik.Web.UI.DialogHandler.axd" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<remove name="Telerik_Web_UI_DialogHandler_axd"/>
<add name="Telerik_Web_UI_DialogHandler_axd" path="Telerik.Web.UI.DialogHandler.axd" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode"/>
</handlers>
</system.webServer>
and after that to set the RadEditor's DialogHandlerUrl property to "~/Telerik.Web.UI.DialogHandler.axd", i.e.
I got this error today when copying a published copy of a site from one server to another.
I figured that I shouldn't have to modify any scripts or code to get it to work again, after all, the site still worked just fine on its old server it is still being hosted on.
This is what I believe happened:
I copied the site files over, hooked up a site and bindings to it in IIS, and then tried to run it.
I got errors, and was forced to modify file handler bindings, the .net framework version of the app pool, and install new server roles/features to get it to at least produce this error.
I then deleted everything in the folder and re-copied the site files and it started working again.
IIS must have modified my site files in some way that prevented the site from working, and restoring the original code fixed it.
I know this is a very specific set of circumstances, but hopefully if someone else has the same situation some day they can solve it in the same simple way that I did.
I have a handler, on runtime it create a watermark on images from a specific folder. The problem is that it worked, but now it doesn't.
All that I did was to changed the hosting.
My web.config looks like this:
<handler>
<add verb="*" name="ImageWatermarkHandler" type="ImageWatermarkHandler"
path="Pics/*.jpg,Pics/*.png" modules="IsapiModule"
scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll"
resourceType="Unspecified" preCondition="integratedMode" />
</handler>
Can you please help me?
Under IIS 7, you have to specify custom http handlers and modules under the configuration/system.webServer/handlers element of your web.config (unlike older IIS versions, where the element is configuration/system.web/httpHandlers).
There's difference between integrated mode (you only need the handlers part) and classic mode(you need both handlers and httpHandlers). For details see the MSDN entry
Edit: At first I haven't noticed the precondition for integrated mode, could it be that the new hosting runs your app in classic mode?
your config file should look like this,
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="Pics/*.jpg,Pics/*.png" type="ImageWatermarkHandler"/>
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add verb="*" path="Pics/*.jpg,Pics/*.png" name="ImageWatermarkHandler" type="ImageWatermarkHandler"/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
for more information,
http://msdn.microsoft.com/en-us/library/bb515343.aspx
Please help with HttpHandler
There is a HttpHandler that handles links to mysite.ru.
Registered in Web.Config as follows:
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="mysite.ru" type="App_Code.SyncHttpHandler"/>
</httpHandlers>
</system.web>
</configuration>
Now through the Handler open only references of the form:
mysite.ru
mysite.ru/struct/
mysite.ru/articles/
How to make the handler to intercept and treatment on the links of the form:
mysite.ru/files/images/img.jpg
mysite.ru/files/scripts/script.js
If I write so that you can run any links, including SyncHttpHandler/Google.ru.
And I need to be able to run only links a specific site.
<add verb="*" path="mysite.ru/*.*" type="App_Code.SyncHttpHandler"/> don't work
<add verb="*" path="*.*" type="App_Code.SyncHttpHandler"/> open any links
<httpHandlers>
<add verb="*" path="*.js" validate="false" type="SyncHttpHandler" />
<add verb="*" path="*.jpg" validate="false" type="SyncHttpHandler" />
</httpHandlers>
you can use this.
Typically, IIS process all static files by its own static file handler. So you need to first configure your IIS to pass all files (extensions) under this path to ASP.NET run-time. Exact steps (although similar) will depend upon IIS version - for example, see here for IIS 6.
Next part would be making sure that ASP.NET runtime passes all those requests to your handler. As such, I think that your config should work but if it doesn't then try using wild-cards. For example,
<add verb="*" path="mysite.ru/*.*" type="App_Code.SyncHttpHandler"/>
or perhaps,
<location path="mysite.ru" >
<system.web>
<add verb="*" path="*.*" type="App_Code.SyncHttpHandler"/>
</system.web>
</location>
In my ASP.Net 1.1 application, i've added the following to my Web.Config (within the System.Web tag section):
<httpHandlers>
<add verb="*" path="*.bcn" type="Internet2008.Beacon.BeaconHandler, Internet2008" />
</httpHandlers>
This works fine, and the HTTPHandler kicks in for files of type .bcn, and does its thing.. however for some reason all ASMX files stop working. Any idea why this would be the case?
Cheers
Greg
I got it... CQ you were on the right track.. i did need to add the .asmx handler again, but the .net 1.1 specific one. Final code is as follows:
<httpHandlers>
<add verb="*" path="*.bcn" type="Internet2008.Beacon.BeaconHandler, Internet2008" validate="false" />
<add verb="*" path="*.asmx" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
</httpHandlers>
I hope there's no other file types that are not getting handled properly because of this declaration. :|
Thanks for the help
greg
It sounds like it as an inherant <clear /> in it although I don't know if I've seen this behaviour before, you could just add the general handler back, let me find you the code.
<add verb="*" path="*.asmx" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services" validate="false">
I think thats the right element, give it a shot.
EDIT: That is odd, I don't have a copy of 2003 on this machine so I can't open a 1.1 but I thought that was the right declaration. You could try adding validate="false" into each element and see if that makes a difference.