locked
Routing Problem (WebResource.axd) RRS feed

  • Question

  • User1577072732 posted

    Hi

    I'm trying to use Routing but i'm having problems. I'm developing under Windows XP

    Web.Config

    <httpModules>
    ...
    <add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule"/>
           

    Globa.asax
     void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }
        private void RegisterRoutes(RouteCollection Routes)
        {  
            Route r = new Route("{page}", new roteamento());
            Routes.Add(r);
        }

    Class Roteamento
    using System.Web.Routing;
    using System.Web;
    using System.Web.UI;
    using System.Web.Compilation;
    
    public class roteamento : IRouteHandler
    {
        public string virtualPath;
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
              string virtualPath = string.Format("~/Paginas/{0}.aspx", requestContext.RouteData.GetRequiredString("page"));   
            return (Page)BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page));
    
        }
    }


    All the pages are in /Paginas/

    When i try to run the Website with Homepage (there's an Homepage.aspx in Paginas), i get this error:
    The File '/My-Project/Paginas/WebResource.axd.aspx' doesn't exist'

    I can't understand why he's calling WebResource.axd.aspx

    On Autos the virtualPath string is "~/Paginas/ScriptResource.axd.aspx"

    Am i doing something wrong?

    Thanks in advance


    Monday, December 14, 2009 8:01 PM

Answers

All replies

  • User-434868552 posted

    http://www.asp.net/learn/mvc/tutorial-21-cs.aspx

    http://www.asp.net/learn/mvc/tutorial-05-cs.aspx

    if you create the tutorial #21 above,
    you'll get routes like #5 above.

    Here, from #5:

            public static void RegisterRoutes(RouteCollection routes)
    {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = "" } // Parameter defaults
    );

    }


    You do not have the IgnoreRoute.  I am guessing that is likely the cause of your problem.


    Regards,
    Gerry (Lowry)

    Monday, December 14, 2009 10:19 PM
  • User-434868552 posted

    Routing links:

    Routes are processed top down, first match is route used.  You'll probably need the ability to debug your routes:

    The first rule that fits the URL is the one that gets used.  Default rules should be last.

    The most general default rule should be the very last.

    There's a really interesting tool and video that you might want to check out:

    the RouteDebug dll tool is discussed in the last twenty minutes*
    of Phil Haack's video:  http://videos.visitmix.com/MIX09/T44F,
                   "Ninja on Fire Black Belt Tips". 

            * Watch the entire video, it's worth your time. 

    ASP.NET MVC documentation is at MSDN:   Reference .

    Routing is here:
    http://msdn.microsoft.com/en-us/library/system.web.routing.aspx
    http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.aspx

    see also:  http://weblogs.asp.net/rashid/archive/2009/04/03/asp-net-mvc-best-practices-part-2.aspx
                   http://www.asp.net/learn/mvc/tutorial-23-cs.aspx == Creating Custom Routes

    for IgnoreRoute see:
    http://msdn.microsoft.com/en-us/library/dd505203.aspx in
    http://msdn.microsoft.com/en-us/library/system.web.mvc.routecollectionextensions.aspx.

     

    ASP.NET MVC Routing

     

    video:  http://www.asp.net/learn/mvc-videos/video-399.aspx.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 14, 2009 10:21 PM
  • User1577072732 posted

    http://www.asp.net/learn/mvc/tutorial-21-cs.aspx

    http://www.asp.net/learn/mvc/tutorial-05-cs.aspx

    if you create the tutorial #21 above,
    you'll get routes like #5 above.

    Here, from #5:

            public static void RegisterRoutes(RouteCollection routes)
    {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = "" } // Parameter defaults
    );

    }


    You do not have the IgnoreRoute.  I am guessing that is likely the cause of your problem.


    Regards,
    Gerry (Lowry)

    Unfortunnaly i'm not using MVC, i was trying to use Routing without MVC.
    The IgnoreRoute is not supported by RouteCollection (i'm developing on .NET 3.5). So, i tried to use Remove and i sucefully removed the WebResource.axd.aspx.
    After this, i had a new error about the ScriptResource.axd.aspx.
    I've used Routes.Remove to this one too, and now i'm getting again the error about WebResource.axd.aspx.


     Route r = new Route("{page}", new roteamento());
            Routes.Remove(RouteTable.Routes["WebResource.axd.aspx"]);
            Routes.Remove(RouteTable.Routes["ScriptResource.axd.aspx"]);
            Routes.Add(r);

    I can't understand why this is happen. A few days ago, i've developed a simple example about using Routing without MVC and everything worked out.

    One more question that i have. About the System.Web.Routing.dll, when i host this project in my hosting, do they need to install the Routing.dll?

    Thanks for your help

    Tuesday, December 15, 2009 11:15 AM
  • User-434868552 posted

    Quick, partial answer:

    System.Web.Routing.dll is an essential component for routing; if your ISP has not installed it and is unwilling to install it, AFAIK, you will only have the option of bin deploying it.

     

    Regards,
    Gerry (Lowry) 

    Tuesday, December 15, 2009 12:26 PM
  • User1577072732 posted

    After send them an email, they told me that they don't have System.Web.Routing.ddl installed on web host server (wich is really bad for a hosting company but wherever).

    I'll try to find some articles explaining how to install it in Bin folder.


    Tuesday, December 15, 2009 1:04 PM
  • User-109060882 posted

    Regarding the hoster, they should install .NET Framework 3.5 Service Pack 1 because that is where System.Web.Routing.dll comes from.

    Regarding the "AXD" routes, you really do need them. Removing them from the route table is incorrect. If you want to see the source code for the IgnoreRoute extension method, check out the MVC source code here: http://aspnet.codeplex.com/sourcecontrol/changeset/view/23011?projectName=aspnet#266514

    Just copy the implementation of the IgnoreRoute() methods and the internal route implementation (it's only ~30 lines of code or so) and use it in your global.asax.cs.

    Thanks,

    Eilon

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 15, 2009 4:17 PM
  • User-434868552 posted

    Regarding the hoster, they should install .NET Framework 3.5 Service Pack 1 because that is where System.Web.Routing.dll comes from.
     

    Some hosters do not care.  1&1 AFAIK is probably still at 2.0 for example.

    I'm assuming bin deployment is an alternative.

       gerry

    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    @ guilherme-cardoso ....

    http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx

    more at http://lmgtfy.com/?q=asp.net+mvc+bin+deploy

    Tuesday, December 15, 2009 6:46 PM
  • User-109060882 posted

    ASP.NET MVC is not supported on ASP.NET 3.5 without SP1. Things might appear to work at first but then a lot of stuff wil stop working. In other words, please do not deploy an ASP.NET MVC application to a web server that has only .NET 3.5 on it without Service Pack 1.

    Thanks,

    Eilon

    Tuesday, December 15, 2009 6:52 PM
  • User-434868552 posted

    ASP.NET MVC is not supported on ASP.NET 3.5 without SP1. Things might appear to work at first but then a lot of stuff wil stop working. In other words, please do not deploy an ASP.NET MVC application to a web server that has only .NET 3.5 on it without Service Pack 1.

     

    Hi Eilon ... this creates a real problem ... there are hosting companies that will not upgrade to even 3.5, let alone 3.5 SP1.

    If guilherme-cardoso's hoster is such a company, she has at least three options:
    (a) give up on ASP.NET MVC
    (b) switch hosting company*
    (c)  attempt to successfully bin deploy the components that her hosting company refuses to provide.

    g.

    * sometimes there are financial penalties for switching.
       I switched from shared hosting with 1&1 to a dedicated server
       with corenetworks so now I have iis 7.5, SQL 2008, and Server 2008 R2;
       not everybody can afford to do this, even at corenetworks' very reasonable prices, 
       (as my mother often said:  "money does not grow on trees".)

    Thursday, December 17, 2009 9:09 AM
  • User1577072732 posted

    I'm starting to think that maybe i'll have to change my hosting company.

    I've added the two dll (Routing and Abstractions to folder Bin and i've add it in web.config assemblies:

    <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        


    I've copied the dll from "..\Programs\Reference Assemblies\Microsoft\Framework\v3.5", so i supose that those are the correct dlls that i need to use.
    When i try to debug on local (my pc) it works fine, when i send it to the hosting it gives the default error plesk: http://teste.ar-informatica.org/Inicio

    After i added the dlls to Bin, is there any other suggestion? Because web hosting companies in Portugal supporting .NET (even 2.0) are not cheap, no they aren't!

    By the way, i'm trying to not use MVC for Routing. I'm trying to route without MVC, just .NET 3.5

    Thanks

    Thursday, December 17, 2009 6:29 PM
  • User-434868552 posted

     @ guilherme-cardoso 

    your hosting company can be anywhere on earth as long as the majority of your end users get decent performance most of the time.

    a decent hosting company will not necessarilly cost you more than you are now paying ... I'm curious how much  you are being charged.

    I have a dedicated server from http://corenetworks.net/ ... I pay about U.S.$75 per month; the first month was more because I wanted a second hard disk and more RAM so I paid a one time fee to have that.  If you share such a system with a few of your good friends, you could possibly pay less than whatever you are currently paying.

    Plus, I got to choose my O/S (Win2008 R2, iis 7.5) and my version of SQL Server (2008 Web version).  When .NET 4 is out, I can add it myself.  This is better than begging an ISP to get up to date.

     

    Regards,
    Gerry (Lowry)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 18, 2009 3:59 PM