Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a mvc4.5 project where I am using the embedded id to create an image using the CaptchaHtmlHelper
the config file is as bellow
XML
<system.web>
        <compilation targetFramework="4.5.1" />
        <customErrors mode="Off" defaultRedirect="Error"></customErrors>
        <httpRuntime targetFramework="4.5.1" />
        <httpHandlers>          
            <remove verb="*" path="*.asmx"/>
            <add verb="*" path="LanapCaptcha.axd" type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect" />
       </httpHandlers>  
 <handlers>
      <!-- Register the HttpHandler used for BotDetect Captcha 
      requests (IIS 7.0+) -->
      <remove name="LanapCaptchaHandler" />
      <add name="LanapCaptchaHandler" verb="*" path="LanapCaptcha.axd" type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect" />    
    </handlers>  

and in my Global.asax.cs file I have set the route as
C#
public class MvcApplication : System.Web.HttpApplication
	{
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Login", action = "Index", id = UrlParameter.Optional }
            );
            
        }       

		protected void Application_Start()
		{
			AreaRegistration.RegisterAllAreas();
			FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
			//RouteConfig.RegisterRoutes(RouteTable.Routes);
			BundleConfig.RegisterBundles(BundleTable.Bundles);
		}

when I load the page I get the following error
XML
Server Error in '/secure/account' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /secure/account/LanapCaptcha.axd

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408

appreciate if you any one show me what I have to do.
thanks a lot
Posted

issue was with the mvc routing. I have to put the routing as bellow
C#
routes.MapRoute(
              "RootPages_default",
              "RootPages/{controller}/{action}/{id}",
              new { controller = "Home", action = "Index", id = UrlParameter.Optional }
          );
 
Share this answer
 
<add verb="*" path="LanapCaptcha.axd" type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect" />

Your error path is

Requested URL: /secure/account/LanapCaptcha.axd

Is that where it lives ? I think you need to start with a \ and specify the full path to the axd file, if that's not where it is. If it IS there, I'd wonder if

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

is causing issues.

Did you know you can specify routes using the Route attribute directly in the controller ?
 
Share this answer
 
Comments
rushdy20 23-Jan-14 4:12am    
could you show me with an example please
Christian Graus 23-Jan-14 4:27am    
You mean to specify routes ?


[Route("ImageData/GetThumbnail/{id}")]

is from my code, underneath is the GetThumbnail method of my ImageData WebAPI controller, and it takes an id parameter. But, I could have made the URL anything I wanted.
rushdy20 23-Jan-14 5:43am    
I think the issue is because my mvc project route starts at http://server/secure/account' when I did a test project where to route url start as localhost:5860/Home/Index the capture is working fine. so is that any think to do with the route? still not working
Christian Graus 23-Jan-14 16:27pm    
You can route the URL to any path you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900