httphandler path doesn't match any path after * - asp.net

I wrote an handler that should work for all the following urls:
.../assert/a.png
.../assert/a/b.png
.../assert/a/b/c.png
but works only with the first one, here it is my code in the web.config file:
<customHandlers>
<handler trigger="~/assert/" handler="CasImagesHandler.ashx"/>
</customHandlers>
<handlers>
<add verb="*" path="*/assert/*.png" type="xxx.CasImagesHandler, xxx" name="CasImagesHandler"/>
</handlers>
<httpHandlers>
<add verb="*" path="*/assert/*.png" type="xxx.CasImagesHandler, xxx" name="CasImagesHandler"/>
</httpHandlers>
Thanks for help

Related

Telerik SpellChecker: RadEditor requires a HttpHandler registration in web.config

I am creating a web app in asp.net, I have a Radeditor, when I clicked on Ajax spellcheck, I am getting the error of
Web.Config Registration Missing!
The SpellChecking Functionality 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.
Telerik.Web.UI.SpellCheckHandler.axd
My web.config look like the below
HttpHandler
<httpHandlers>
<add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="true" />
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
<add path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler" validate="false" />
<add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false" />
</httpHandlers>
Handler
<handlers>
<remove name="ChartImageHandler" />
<remove name="Telerik_RadUploadProgressHandler_ashx" />
<remove name="Telerik_Web_UI_WebResource_axd" />
<remove name="Telerik_Web_UI_DialogHandler_aspx" />
<remove name="Telerik_Web_UI_SpellCheckHandler_axd" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode" />
<add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.axd" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode" />
<add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode" />
<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode" />
</handlers>
Location
<location path="Telerik.Web.UI.WebResource.axd">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Error on page
What else should I add in web.config, as I try to work with This solution but still facing the same problem
After Implementing Rumen Jekov Solution, I am still getting the error
Regarding the Spell Check Handler Server Error, AjaxUrl property is used to set the path to the handler and is used in scenarios where you may have a UrlRewriter module which overwrites the handlers url even if they are set in the web.config. A correct value of this property is like follows: RadEditor1.SpellCheckSettings.AjaxUrl = "Telerik.Web.UI.SpellCheckHandler.aspx";
Once you set the new AjaxUrl value, go to the web.config file and update the Telerik.Web.UI.SpellCheckHandler.axd instances to Telerik.Web.UI.SpellCheckHandler.aspx
Check this article for more information about problems with handlers: https://www.telerik.com/support/kb/aspnet-ajax/editor/details/error-web-config-registration-missing!-the-telerik-dialogs-require-a-httphandler-registration-in-the-web-config-file-

Handle dot at the end of URL in routing

I've got an Asp.Net MVC 5 website. In Web.config file, I have these in the handlers section:
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="UrlRoutingHandler" type="System.Web.Routing.UrlRoutingHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" path="/user/*" verb="GET" />
</handlers>
Basically I want everything after the website.com/user/... to be captured by the UserController. But unfortunately it doesn't work if it ends with a dot . For instance:
website.com/user/test.
How can I change it to fix this issue?

Prevent access to aspx files and allow access only via routing?

I have a url route which I declare at global.asax file :
routes.MapPageRoute("RouteAdmin", "Admin/{Url}", "~/pages/MyPage.aspx", false);
But if the user tries to access mysite.com/pages/MyPage.aspx he can still see the page
Question :
Can I configure routing so that only routed paths are acceptable ?
In ASP.NET MVC views are not accessible directly by defining them using a not found handler:
<system.web>
<httpHandlers>
<remove verb="*" path="*.aspx" />
<add path="*.aspx" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="BlockViewHandler" path="*.aspx" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
Found it.
If I access directly to the aspx file so I can check this prop:
Page.RouteData.RouteHandler is null
where
if I use route url it is not null :
{System.Web.Routing.PageRouteHandler}
Edit
(better solution)
Add those 2 lines to global asax
routes.MapPageRoute("Route", "{*.}", "~/pages/default.aspx", false );
routes.RouteExistingFiles = true;

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

IIS 7 handler mapings & asp.net *.htm page routing with WebForm. How to route *.htm like *.aspx?

I am trying to make the *.htm files processable by .net to route this extension, but I am unable until now. I search through tons of results on google/bing, I found something to make the mapping and to route it, but it's not working.
Note that I am using webForm, not mvc.
The mapping set in IIS is Managed Handler : path=*.htm, Handler=System.Web.UI.SimpleHandlerFactory
Here the code I am using.
Am I missing something?
Thanks!
//Web.config
<system.web>
<httpModules>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModue,System.Web.Routing,Version=4.0.0.0,Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
<httpHandlers>
<add verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler,System.Web, Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />
<add verb="*" path="*.htm" type="System.Web.UI.PageHandlerFactory"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</handlers>
</system.webServer>
//global.asax.cs
void RegisterRoutes(RouteCollection routes){
routes.Ignore("{ressources}.asd/{*pathInfo}");
routes.MapPageRoute("OnlineHelp", "Help/Content/{HelpFile}.htm", "~/Default.aspx");
routes.MapPageRoute("Default", "", "~/Default.aspx",true);
}

Resources