HighTechTalks DotNet Forums  

MVC Framework - Routing

Dotnet Framework microsoft.public.dotnet.framework


Discuss MVC Framework - Routing in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Chris Marsh
 
Posts: n/a

Default MVC Framework - Routing - 12-23-2007 , 03:04 PM






All

I've just stated playing with the MVC framework included in the ASP .NET
Extensions release, but I'm hving trouble with the default settings.

I have created a default ASP .NET MVC Web Application, which includes a
default controller (HomeController) and two default views (Index and About).
The routes in Global.asax are as follows:

RouteTable.Routes.Add(new Route
{

Url = "[controller]/[action]/[id]",

Defaults = new { action = "Index", id = (string)null },

RouteHandler = typeof(MvcRouteHandler)

});

RouteTable.Routes.Add(new Route

{

Url = "Default.aspx",

Defaults = new { controller = "Home", action = "Index", id = (string)null },

RouteHandler = typeof(MvcRouteHandler)

});

However, only the second route appears to work. I would expect the first to
allow access to the Index page in a browser via the URL
http://localhost/Home/Index, but this gives an HTTP 404 error. I have
changed nothing in the default application, I have just built it and
attempted to access the pages in a browser. Can anyone give me any pointers
as to why this route does not appear to work?

Many thanks for any assistance!

--
Regards

Chris Marsh



Reply With Quote
  #2  
Old   
Chris Marsh
 
Posts: n/a

Default Re: MVC Framework - Routing - 12-23-2007 , 07:11 PM






All

I've just discovered that everything works fine when running the application
from Visual Studio; using F5 to launch the debugger.

Any pointers would be very much appreciated.

--
Regards

Chris Marsh

"Chris Marsh" <cjmarsh (AT) newsgroup (DOT) nospam> wrote

Quote:
All

I've just stated playing with the MVC framework included in the ASP .NET
Extensions release, but I'm hving trouble with the default settings.

I have created a default ASP .NET MVC Web Application, which includes a
default controller (HomeController) and two default views (Index and
About). The routes in Global.asax are as follows:

RouteTable.Routes.Add(new Route
{

Url = "[controller]/[action]/[id]",

Defaults = new { action = "Index", id = (string)null },

RouteHandler = typeof(MvcRouteHandler)

});

RouteTable.Routes.Add(new Route

{

Url = "Default.aspx",

Defaults = new { controller = "Home", action = "Index", id =
(string)null },

RouteHandler = typeof(MvcRouteHandler)

});

However, only the second route appears to work. I would expect the first
to allow access to the Index page in a browser via the URL
http://localhost/Home/Index, but this gives an HTTP 404 error. I have
changed nothing in the default application, I have just built it and
attempted to access the pages in a browser. Can anyone give me any
pointers as to why this route does not appear to work?

Many thanks for any assistance!

--
Regards

Chris Marsh





Reply With Quote
  #3  
Old   
Cowboy \(Gregory A. Beamer\)
 
Posts: n/a

Default Re: MVC Framework - Routing - 12-26-2007 , 10:59 AM



I have detailed the wiring of MVC on my blog.
http://gregorybeamer.spaces.live.com...34A8!459.entry

This is a very basic blog entry. Check Scott Guthrie's
(http://weblogs.asp.net/scottgu/) and Scott Hanselman's
(http://www.hanselman.com/blog/) blog for more detailed entries.

You should also check out Phil Haack's blog, especially if you are into TDD.
http://haacked.com/

Palermo has also written an article for Code magazine:
http://www.code-magazine.com/Article...quickid=070173

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
Quote:
Think outside the box!

*************************************************
"Chris Marsh" <cjmarsh (AT) newsgroup (DOT) nospam> wrote

Quote:
All

I've just discovered that everything works fine when running the
application from Visual Studio; using F5 to launch the debugger.

Any pointers would be very much appreciated.

--
Regards

Chris Marsh

"Chris Marsh" <cjmarsh (AT) newsgroup (DOT) nospam> wrote in message
news:%23g4$tdaRIHA.1168 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
All

I've just stated playing with the MVC framework included in the ASP .NET
Extensions release, but I'm hving trouble with the default settings.

I have created a default ASP .NET MVC Web Application, which includes a
default controller (HomeController) and two default views (Index and
About). The routes in Global.asax are as follows:

RouteTable.Routes.Add(new Route
{

Url = "[controller]/[action]/[id]",

Defaults = new { action = "Index", id = (string)null },

RouteHandler = typeof(MvcRouteHandler)

});

RouteTable.Routes.Add(new Route

{

Url = "Default.aspx",

Defaults = new { controller = "Home", action = "Index", id =
(string)null },

RouteHandler = typeof(MvcRouteHandler)

});

However, only the second route appears to work. I would expect the first
to allow access to the Index page in a browser via the URL
http://localhost/Home/Index, but this gives an HTTP 404 error. I have
changed nothing in the default application, I have just built it and
attempted to access the pages in a browser. Can anyone give me any
pointers as to why this route does not appear to work?

Many thanks for any assistance!

--
Regards

Chris Marsh







Reply With Quote
  #4  
Old   
Chris Marsh
 
Posts: n/a

Default Re: MVC Framework - Routing - 12-27-2007 , 05:59 PM



Gregory

Thanks very much for the informative links. It transpired that my problem
stemmed from my use if IIS6. Although I followed instructions and used a
..mvc suffix, I had not registered this suffix with IIS for hand-off to the
ASP .NET ISAPI filter.

I've learnt a lot along the way though, so despite the frustration over
something small it's been a worthwhile experience

Cheers!

--
Regards

Chris Marsh

"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld (AT) comcast (DOT) netNoSpamM> wrote in
message news:uUewgC%23RIHA.5360 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
Quote:
I have detailed the wiring of MVC on my blog.
http://gregorybeamer.spaces.live.com...34A8!459.entry

This is a very basic blog entry. Check Scott Guthrie's
(http://weblogs.asp.net/scottgu/) and Scott Hanselman's
(http://www.hanselman.com/blog/) blog for more detailed entries.

You should also check out Phil Haack's blog, especially if you are into
TDD.
http://haacked.com/

Palermo has also written an article for Code magazine:
http://www.code-magazine.com/Article...quickid=070173

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
"Chris Marsh" <cjmarsh (AT) newsgroup (DOT) nospam> wrote in message
news:OcSI3ncRIHA.3940 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
All

I've just discovered that everything works fine when running the
application from Visual Studio; using F5 to launch the debugger.

Any pointers would be very much appreciated.

--
Regards

Chris Marsh

"Chris Marsh" <cjmarsh (AT) newsgroup (DOT) nospam> wrote in message
news:%23g4$tdaRIHA.1168 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
All

I've just stated playing with the MVC framework included in the ASP .NET
Extensions release, but I'm hving trouble with the default settings.

I have created a default ASP .NET MVC Web Application, which includes a
default controller (HomeController) and two default views (Index and
About). The routes in Global.asax are as follows:

RouteTable.Routes.Add(new Route
{

Url = "[controller]/[action]/[id]",

Defaults = new { action = "Index", id = (string)null },

RouteHandler = typeof(MvcRouteHandler)

});

RouteTable.Routes.Add(new Route

{

Url = "Default.aspx",

Defaults = new { controller = "Home", action = "Index", id =
(string)null },

RouteHandler = typeof(MvcRouteHandler)

});

However, only the second route appears to work. I would expect the first
to allow access to the Index page in a browser via the URL
http://localhost/Home/Index, but this gives an HTTP 404 error. I have
changed nothing in the default application, I have just built it and
attempted to access the pages in a browser. Can anyone give me any
pointers as to why this route does not appear to work?

Many thanks for any assistance!

--
Regards

Chris Marsh









Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.