Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 20, 2012 02:03 PM by Maziyar.Developer
Member
22 Points
14 Posts
May 20, 2012 06:22 AM|LINK
hello everybody
i have 2 page with names : Default.aspx , ArchiveOne.aspx
i in file Global.asax this code following write :
void RegisterRoutes(RouteCollection routs) { routs.MapPageRoute( "aspdotnet", "Archives/~/ArchiveOn/{ID}", "~/ArchiveOn.aspx"); Context.RewritePath("~/ArchiveOn.aspx", true); } void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); }
and in Default.aspx.cs
string res = dtr["titles"].ToString(); string ss = res.Replace(" ", "-"); sp = dtr["dates"].ToString(); string sa = sp.Replace("-", "/"); HtmlGenericControl divdate = new HtmlGenericControl("div"); divdate.InnerHtml = " <a href='/Archives/" + sa + "/ArchiveOn/" + ss + "'" + ">Comment</a>";
but after run default.aspx and click link 1 error -->The resource cannot be found -- > Archives/2010/05/05/Archiveon/textall
but in link2 not error but if refresh error -- > The resource cannot be found -- > Archives/2010/05/05/Archiveon/textall2
help ???
thanks
Star
12536 Points
1867 Posts
May 20, 2012 09:30 AM|LINK
Maziyar.Developer routs.MapPageRoute( "aspdotnet", "Archives/~/ArchiveOn/{ID}", "~/ArchiveOn.aspx");
routs.MapPageRoute( "aspdotnet", "Archives/~/ArchiveOn/{ID}", "~/ArchiveOn.aspx");
there is problem with you route. Why you are using ~ in your route ?
see following link
http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx
May 20, 2012 01:22 PM|LINK
How can I make the date as the virtual path after "Archives" before "ArchiveOn"???
May 20, 2012 02:03 PM|LINK
I found the solution here, maybe it others confronted with this problem.
if you want address url This show example ---> ArchiveOn/2010/05/06/aspnetmvc
must this code alternative :
routs.MapPageRoute( "aspdotnet", "ArchiveOn/{Year}/{Month}/{Day}/{ID*}", "~/ArchiveOn.aspx");
Quoting from the site msdn microsoft : http://msdn.microsoft.com/en-us/library/dd992955.aspx
Maziyar.Deve...
Member
22 Points
14 Posts
url rewrite in asp.net 4.0 error 404
May 20, 2012 06:22 AM|LINK
hello everybody
i have 2 page with names : Default.aspx , ArchiveOne.aspx
i in file Global.asax this code following write :
void RegisterRoutes(RouteCollection routs) { routs.MapPageRoute( "aspdotnet", "Archives/~/ArchiveOn/{ID}", "~/ArchiveOn.aspx"); Context.RewritePath("~/ArchiveOn.aspx", true); } void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); }and in Default.aspx.cs
string res = dtr["titles"].ToString(); string ss = res.Replace(" ", "-"); sp = dtr["dates"].ToString(); string sa = sp.Replace("-", "/"); HtmlGenericControl divdate = new HtmlGenericControl("div"); divdate.InnerHtml = " <a href='/Archives/" + sa + "/ArchiveOn/" + ss + "'" + ">Comment</a>";but after run default.aspx and click link 1 error -->The resource cannot be found -- > Archives/2010/05/05/Archiveon/textall
but in link2 not error but if refresh error -- > The resource cannot be found -- > Archives/2010/05/05/Archiveon/textall2
help ???
thanks
Nasser Malik
Star
12536 Points
1867 Posts
Re: url rewrite in asp.net 4.0 error 404
May 20, 2012 09:30 AM|LINK
there is problem with you route. Why you are using ~ in your route ?
see following link
http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx
Skype: maleknasser1
Maziyar.Deve...
Member
22 Points
14 Posts
Re: url rewrite in asp.net 4.0 error 404
May 20, 2012 01:22 PM|LINK
How can I make the date as the virtual path after "Archives" before "ArchiveOn"???
Maziyar.Deve...
Member
22 Points
14 Posts
Re: url rewrite in asp.net 4.0 error 404
May 20, 2012 02:03 PM|LINK
I found the solution here, maybe it others confronted with this problem.
if you want address url This show example ---> ArchiveOn/2010/05/06/aspnetmvc
must this code alternative :
routs.MapPageRoute( "aspdotnet", "ArchiveOn/{Year}/{Month}/{Day}/{ID*}", "~/ArchiveOn.aspx");Quoting from the site msdn microsoft : http://msdn.microsoft.com/en-us/library/dd992955.aspx
thanks