url rewrite in asp.net 4.0 error 404http://forums.asp.net/t/1805471.aspx/1?url+rewrite+in+asp+net+4+0+error+404Sun, 20 May 2012 14:03:00 -040018054714988468http://forums.asp.net/p/1805471/4988468.aspx/1?url+rewrite+in+asp+net+4+0+error+404url rewrite in asp.net 4.0 error 404 <p>hello everybody</p> <p>i have 2 page with names : Default.aspx , ArchiveOne.aspx</p> <p>i in file Global.asax this code following write :</p> <pre class="prettyprint">void RegisterRoutes(RouteCollection routs) { routs.MapPageRoute( &quot;aspdotnet&quot;, &quot;Archives/~/ArchiveOn/{ID}&quot;, &quot;~/ArchiveOn.aspx&quot;); Context.RewritePath(&quot;~/ArchiveOn.aspx&quot;, true); } void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); }</pre> <p>and in Default.aspx.cs</p> <pre class="prettyprint">string res = dtr["titles"].ToString(); string ss = res.Replace(" ", "-"); sp = dtr["dates"].ToString(); string sa = sp.Replace("-", "/"); HtmlGenericControl divdate = new HtmlGenericControl("div"); divdate.InnerHtml = "&amp;nbsp;&lt;a href='/Archives/" + sa + "/ArchiveOn/" + ss + "'" + "&gt;Comment&lt;/a&gt;";</pre> <p>but&nbsp;after run default.aspx and click link 1 error&nbsp;--&gt;<i>The resource cannot be found -- &gt; Archives/2010/05/05/Archiveon/textall</i></p> <p>but in&nbsp;link2 not error but&nbsp;if refresh&nbsp;error&nbsp;-- &gt;&nbsp;<i>The resource cannot be found -- &gt; Archives/2010/05/05/Archiveon/textall2</i></p> <p>help ???</p> <p>thanks&nbsp;</p> 2012-05-20T06:22:09-04:004988584http://forums.asp.net/p/1805471/4988584.aspx/1?Re+url+rewrite+in+asp+net+4+0+error+404Re: url rewrite in asp.net 4.0 error 404 <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Maziyar.Developer</h4> <p></p> <pre class="prettyprint">routs.MapPageRoute( &quot;aspdotnet&quot;, &quot;Archives/~/ArchiveOn/{ID}&quot;, &quot;~/ArchiveOn.aspx&quot;);</pre> <p></p> </blockquote> <p></p> <p>there is problem with you route. Why you are using ~ in your route ?</p> <p>see following link</p> <p><a target="_blank" href="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">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</a></p> <p></p> <p></p> 2012-05-20T09:30:59-04:004988695http://forums.asp.net/p/1805471/4988695.aspx/1?Re+url+rewrite+in+asp+net+4+0+error+404Re: url rewrite in asp.net 4.0 error 404 <p><span class="hps">How</span> <span class="hps">can</span> <span class="hps">I</span> <span class="hps">make</span> <span class="hps alt-edited">the date</span> <span class="hps"> as the</span> <span class="hps">virtual</span> <span class="hps">path</span> after &quot;Archives&quot; before &quot;ArchiveOn&quot;???</p> 2012-05-20T13:22:18-04:004988727http://forums.asp.net/p/1805471/4988727.aspx/1?Re+url+rewrite+in+asp+net+4+0+error+404Re: url rewrite in asp.net 4.0 error 404 <p><span class="hps">I</span> <span class="hps">found the</span> <span class="hps"> solution</span> <span class="hps">here,</span>&nbsp;maybe <span class="hps">it</span> <span class="hps alt-edited"> others</span> <span class="hps alt-edited">confronted</span> <span class="hps">with</span> <span class="hps">this</span> <span class="hps">problem</span><span>.</span></p> <p><span>if you want address url <span class="hps">This</span> <span class="hps"> show example</span>&nbsp;---&gt; ArchiveOn/2010/05/06/aspnetmvc</span></p> <p><span>must this code alternative : </span></p> <pre class="prettyprint">routs.MapPageRoute( &quot;aspdotnet&quot;, &quot;ArchiveOn/{Year}/{Month}/{Day}/{ID*}&quot;, &quot;~/ArchiveOn.aspx&quot;);</pre> <p><span><span class="hps">Quoting from the</span> <span class="hps">site</span> msdn microsoft : <a href="http://msdn.microsoft.com/en-us/library/dd992955.aspx">http://msdn.microsoft.com/en-us/library/dd992955.aspx</a></span></p> <p><span>thanks</span></p> 2012-05-20T14:03:00-04:00