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?
Related
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-
Briefly:
Bundles which contain items from a VirtualPath (Served by custom VirtualPathProvider) don't work. Hash isn't generated in the v= and resolving them shows the .Items property as empty.
Detailed:
Suppose we have a bundle registration:
bundles.Clear();
bundles.ResetAll();
BundleTable.EnableOptimizations = true;
bundles.Add(new StyleBundle("~/bundles/css")
.Include("~/Content/site.css"));
bundles.Add(new StyleBundle("~/bundles/admin/somestyle")
.Include("~/Areas/Admin/Content/css/aaa2.css"));
Some notes here:
~/bundles/admin/somestyle physically doesn't exist.
~/Areas/Admin/Content/css/aaa2.css is a virtual path which is handled by a custom VirtualPathProvider
~/bundles/css is served by default MapPathBasedVirtualPathProvider
Relevant part of current Web.config file:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="false"/>
<handlers>
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="AspNetStaticFileHandler-TIFF" path="*.tiff" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-GIF" path="*.gif" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-PNG" path="*.png" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-JPG" path="*.jpg" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-CSS" path="*.css" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-JS" path="*.js" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-WOFF" path="*.woff" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-TTF" path="*.ttf" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-MAP" path="*.map" verb="*" type="System.Web.StaticFileHandler" />
</handlers>
</system.webServer>
Routing entries:
routes.IgnoreRoute("favicon.ico");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
Test Drive:
1. Trying to access the .css files directly:
http://localhost:1010/Areas/Admin/Content/css/aaa2.css - File found => Custom VirtualPathProvider did his job.
2. Trying to resolve bundles from HomeController:
public ActionResult Test()
{
var bundleVirtual = BundleTable.Bundles.GetBundleFor("~/bundles/admin/somestyle");
var bundleVirtualUrl = BundleTable.Bundles.ResolveBundleUrl("~/bundles/admin/somestyle");
var bundleOrdinary = BundleTable.Bundles.GetBundleFor("~/bundles/css");
var bundleOrdinaryUrl = BundleTable.Bundles.ResolveBundleUrl("~/bundles/css");
return View();
}
bundleVirtual is found but .Items property is empty.
bundleVirtualUrl is /bundles/admin/somestyle?v= notice that v= has no hash value.
bundleOrdinary is found, .Items has one entry ~/Content/site.css.
bundleOrdinaryUrl is "/bundles/css?v=6bMbVqKBetPV3UISUSkpqR5wiBsbzK_c6J21LUZAzaU1"
Question:
Why resolving "~/bundles/admin/somestyle" shows that there are not Items added, even if the item is registered and the VirtualPathProvider handles it correctly?
Related links:
ASP.NET Bundling/Minification and Embedded Resources
http://www.codeproject.com/Articles/728146/ASP-NET-MVC-bundles-internals
You need to register your VirtualPathProvider before bundle registration, in order to be able to find your files. Any files not found will not be included in bundle.Items
var vpp = new MyVirtualPathProvider();
BundleTable.VirtualPathProvider = vpp;
BundleConfig.RegisterBundles(BundleTable.Bundles);
Unless of course you already have it registered as HostingEnvironment.VirtualPathProvider.
Debugging my code in VS, I've seen that Global.asax´s Application_Start method is being called twice:
First when the server starts
Second after login
The login method does:
AuthenticationCookie.SetSessionCookie(userName);
FormsAuthentication.RedirectFromLoginPage(userName, false);
System.Threading.Thread.CurrentPrincipal = user;
The Web.config file is as follows (excluding some 100% unrelated parts):
.
.
.
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<!--
For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<authentication mode="Forms">
<forms loginUrl="SignIn" protection="All" timeout="120" />
</authentication>
<pages controlRenderingCompatibilityVersion="4.0">
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<!--
If you are deploying to a cloud environment that has multiple web server instances,
you should change session state mode from "InProc" to "Custom". In addition,
change the connection string named "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->
<sessionState mode="InProc" customProvider="DefaultSessionProvider" timeout="120">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
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
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);
}