My prototype MVC application was working nicely with controller/action/id urls, and then I updated the references and switched my controller code to the newer versions that return ActionResult objects. This was mainly to take advantage of newer samples of
how to write the tests for ASP.NET MVC. Here is what the new controller code looks like:
public ActionResult Index()
{
//Add action logic here
ViewData["Message"] = "This is the index action calling!";
return View();
}
Then I found that the routing code no longer built so I changed it from this:
routes.Add(new Route("{controller}/{action}/{id}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { action = "Index", id = (string)null }),
});
Now the only url that works is "default.aspx"
The project is set to use the VS Development Server, and apply server settings to all users.
And unfortunately, I didn't keep a log of everything that I updated or re-referenced on this session, so I'm not sure where it went wrong.
Maybe something that I installed reset something else in IIS? I may have to reset my VM and start over, but that will take a while to get everything right again, so I'd rather avoid that if I have to.
You mention that the project is set to the dev server, but you mention IIS (the dev server doesn't use IIS). Just in case, I'll cover off a few options.
Is it an IIS 404 or an ASP.NET 404? (An ASP.NET 404 will use the same colour scheme as application errors, an IIS 404 is just in black and white)
If it is an ASP.NET 404, you should double check that the UrlRouteModule is in your HttpModules list (note that both IIS7 and the Dev WebServer use
system.webServer/modules instead of
system.web/httpModules). In fact, this is the most likely culprate
If its an IIS 404, you probably need to configure wildcard mapping (so that all requests go to ASP.NET) in IIS. Again, as you mention Cassini (the VS Web Server) I doubt its this... but this will affect you when you deploy the solution into a Windows Server
2003 environment.
Let me know if the above doesn't help and we'll explore some more options.
My project is referencing System.Web.Abractions and System.Web.Routing in C:\Program Files\Microsoft ASP.NET\ASP.NET MVC Preview 3\Assemblies, not the versions in the GAC, as the GAC versions don't build.
In Preview 3, the Routing/Abstraction assemblies had their version numbers changes to 0.0.0.0 so that they would not conflict with .NET 3.5 SP1 Beta. The PublicKeyToken remains the same, though.
Update both references to the following and ensure the assemblies are being copied to the bin directory (ie. the properties for that reference are set to "copy to output directory"):
My project references are to version 0.0.0.0 of abstractions/routing dlls, so that looks ok.
I manually changed both of the entries in my web.config file, but this is the error that I get when I try to debug it:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load type 'System.Web.Mvc.UrlRoutingModule' from assembly 'System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35'. (C:\somepath\MvcApplication\web.config line 83)
Source Error:
Line 81: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 82: <add name="DynamicDataModule" type="System.Web.DynamicData.DynamicDataHttpModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> Line 83: <add name="UrlRoutingModule" type="System.Web.Mvc.UrlRoutingModule, System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 84: </httpModules>
Line 85: </system.web>
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3031; ASP.NET Version:2.0.50727.3031
I had just figured that one out, and I guess I just I posted my follow up about that at the exact same time you did, because mine didn't show up. In any case, thanks very much for your help, now I can get back to figuring how to use the MVC architecture.
marcel_g
Member
7 Points
18 Posts
Routing busted - 404 on all routes
Jul 07, 2008 05:33 PM|LINK
My prototype MVC application was working nicely with controller/action/id urls, and then I updated the references and switched my controller code to the newer versions that return ActionResult objects. This was mainly to take advantage of newer samples of how to write the tests for ASP.NET MVC. Here is what the new controller code looks like:
public ActionResult Index() { //Add action logic here ViewData["Message"] = "This is the index action calling!"; return View(); }Then I found that the routing code no longer built so I changed it from this:
routes.Add(new Route("{controller}/{action}/{id}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { action = "Index", id = (string)null }),
});
Now the only url that works is "default.aspx"
The project is set to use the VS Development Server, and apply server settings to all users.
And unfortunately, I didn't keep a log of everything that I updated or re-referenced on this session, so I'm not sure where it went wrong.
Maybe something that I installed reset something else in IIS? I may have to reset my VM and start over, but that will take a while to get everything right again, so I'd rather avoid that if I have to.
Thanks,
Marcel
Marcel
richard.szal...
Member
522 Points
124 Posts
Re: Routing busted - 404 on all routes
Jul 07, 2008 06:58 PM|LINK
You mention that the project is set to the dev server, but you mention IIS (the dev server doesn't use IIS). Just in case, I'll cover off a few options.
Is it an IIS 404 or an ASP.NET 404? (An ASP.NET 404 will use the same colour scheme as application errors, an IIS 404 is just in black and white)
If it is an ASP.NET 404, you should double check that the UrlRouteModule is in your HttpModules list (note that both IIS7 and the Dev WebServer use system.webServer/modules instead of system.web/httpModules). In fact, this is the most likely culprate
If its an IIS 404, you probably need to configure wildcard mapping (so that all requests go to ASP.NET) in IIS. Again, as you mention Cassini (the VS Web Server) I doubt its this... but this will affect you when you deploy the solution into a Windows Server 2003 environment.
Let me know if the above doesn't help and we'll explore some more options.
Richard
marcel_g
Member
7 Points
18 Posts
Re: Routing busted - 404 on all routes
Jul 07, 2008 07:29 PM|LINK
It's an ASP.NET 404 error.
Here are the entries from my web.config file:
system.web/modules:
<add name="UrlRoutingModule" type="System.Web.Mvc.UrlRoutingModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
system.webServer/modules:
<add name="UrlRoutingModule" type="System.Web.Mvc.UrlRoutingModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
My project is referencing System.Web.Abractions and System.Web.Routing in C:\Program Files\Microsoft ASP.NET\ASP.NET MVC Preview 3\Assemblies, not the versions in the GAC, as the GAC versions don't build.
Marcel
richard.szal...
Member
522 Points
124 Posts
Re: Routing busted - 404 on all routes
Jul 07, 2008 07:41 PM|LINK
In Preview 3, the Routing/Abstraction assemblies had their version numbers changes to 0.0.0.0 so that they would not conflict with .NET 3.5 SP1 Beta. The PublicKeyToken remains the same, though.
Update both references to the following and ensure the assemblies are being copied to the bin directory (ie. the properties for that reference are set to "copy to output directory"):
System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35
Let me know how that goes.
marcel_g
Member
7 Points
18 Posts
Re: Routing busted - 404 on all routes
Jul 07, 2008 08:04 PM|LINK
Thanks for the help so far.
My project references are to version 0.0.0.0 of abstractions/routing dlls, so that looks ok.
I manually changed both of the entries in my web.config file, but this is the error that I get when I try to debug it:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load type 'System.Web.Mvc.UrlRoutingModule' from assembly 'System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35'. (C:\somepath\MvcApplication\web.config line 83)
Source Error:
Line 81: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 82: <add name="DynamicDataModule" type="System.Web.DynamicData.DynamicDataHttpModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 83: <add name="UrlRoutingModule" type="System.Web.Mvc.UrlRoutingModule, System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 84: </httpModules>
Line 85: </system.web>
Source File: C:\somepath\MvcApplication\web.config Line: 83
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3031; ASP.NET Version:2.0.50727.3031
Marcel
richard.szal...
Member
522 Points
124 Posts
Re: Routing busted - 404 on all routes
Jul 07, 2008 08:09 PM|LINK
Apologies, entirely my fault. The namespace does not include "Mvc". It should be:
System.Web.Routing.UrlRoutingModule
marcel_g
Member
7 Points
18 Posts
Re: Routing busted - 404 on all routes
Jul 07, 2008 08:09 PM|LINK
OK, your suggestion just needed a small change:
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
I changed System.Web.Mvc.UrlRoutingModule to System.Web.Routing.UrlRoutingModule, and now it works.
Thanks a bunch,
marcel
Marcel
marcel_g
Member
7 Points
18 Posts
Re: Routing busted - 404 on all routes
Jul 07, 2008 08:13 PM|LINK
I had just figured that one out, and I guess I just I posted my follow up about that at the exact same time you did, because mine didn't show up. In any case, thanks very much for your help, now I can get back to figuring how to use the MVC architecture.
Marcel
Marcel
richard.szal...
Member
522 Points
124 Posts
Re: Routing busted - 404 on all routes
Jul 07, 2008 08:13 PM|LINK
No worries. I've updated the "answer" post to be correct as to avoid confusion to ther users.