how to modify the routes?
I have asp.net mvc project, and it's structure and routes are as below.
"Site.Master" include images and css files,with paths:
- ../../Images/1.gif
- ../../Content/site.css.
When visiting the page "http://www.localhost.com/Info/Index/1001", it works.
But page "http://www.localhost.com/Info/Index/1001/1" or "http://www.localhost.com/Info/Index/1001开发者_高级运维/2", don't.
I modified the images and css file path in the Site.Master like:
- /Images/1.gif
- /Content/site.css
In addition, is there another way to fix it? or modify routes? Because, i want deploy it using virtual directory in iis.
-> Images
- 1.gif
- 2.jpg
-> Content
- site.css
-> Views
Home
-- index.aspx
Info
-- index.aspx
Shared
-- Site.Master
routes.MapRoute( "InfoPagedRoute", "{controller}/{action}/{classid}/{page}", new { controller = "Info", action = "Index", classid = @"\d{1,10}", page = 1 } );
Your original route:
routes.MapRoute(
"InfoPagedRoute",
"{controller}/{action}/{classid}/{page}",
new { controller = "Info", action = "Index", classid = @"\d{1,10}", page = 1 }
);
It looks like you are trying to use a validator in your route defaults for the classid, so either you need to include a validation parameter or set a default value for the classid.
I would suggest:
routes.MapRoute(
"InfoPagedRoute",
"{controller}/{action}/{classid}/{page}",
new { controller = "Info", action = "Index", classid = 1001, page = 1 }
);
If updating the route doesn't resolve the issue, you could use Phil Haack's route debugger. It is really helpful in figuring out if the route you are expecting to get hit is actually the one that is being used.
精彩评论